Ken Googler the keen koala loves playing Whac-A-Mole at the annual koala carnival. His skill and dexterity make him one of the best Whac-A-Mole players in the west, and to reward his success, the carnival administrator presents him with a line of
Being the dedicated Whac-A-Mole player he is, he returns to the carnival every day over the next
For this problem, Python users are recommended to use PyPy over CPython.
Constraints
It is guaranteed that all stuffed animals within the range from
Subtask 1 [5%]
Subtask 2 [15%]
Subtask 3 [80%]
No additional constraints.
Input Specification
The first line contains the integers
The next line contains the integers
Note that the input will be online enforced. The next
Output Specification
For each unencrypted query
Sample Input 1
5 3
4 5 3 3 2
5 5
3 1
0 0
Sample Input 1 (Unencrypted)
5 3
4 5 3 3 2
5 5
1 3
3 3
Sample Output 1
2
3
3
Explanation for Sample 1
For the first query, Ken must take the fifth stuffed animal. He can also take the fourth stuffed animal, but cannot take the third since it is identical to the fourth. Ken should choose the interval from
For the second query, Ken should choose the interval from
For the third query, Ken should choose the interval from
Sample Input 2
8 5
6 8 2 5 6 7 8 3
3 4
0 14
7 4
7 7
1 14
Sample Input 2 (Unencrypted)
8 5
6 8 2 5 6 7 8 3
3 4
6 8
1 2
3 3
7 8
Sample Output 2
6
6
4
6
6
Comments