Yura own ordinary boring array length n you think boring Vladik do not agreein order Yuras array bore Vladik make q bore query each query consist integer x y before answer query bound l r query calculate l x bmod n 1 r y bmod n 1 answer previous query zero initially bmod remainder operation whenever l r swappedAfter Vladik compute l r query compute common multiple lcm segment l r initial array modulo 109 7 lcm multiset integer smallest positive integer divisible element multiset the obtain lcm answer queryhelp Vladik compute answer query