2724 - [Violet 6]蒲公英

Input

修正一下 l = (l_0 + x - 1) mod n + 1, r = (r_0 + x - 1) mod n + 1

Output

Examples

Input

6 3 
1 2 3 2 1 2 
1 5 
3 6 
1 5 

Output

1 
2 
1 

Hint

修正下:

n <= 40000, m <= 50000

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题