You may perform the following operation any number (including zero) of times on the array A=(a1,a2,…,am):
For example, if we cyclically shift the interval [1,4] of the array A=[1,2,3,4,5] to the right, the resulting array would be A'=[4,1,2,3,5]
You are now given a permutationP=(p1,p2,…,pn) of length n and you need to answer q independent queries of the following form:
The first line contains an integer T(1≤T≤10) denote the number of test cases.
For each test case, the first line contains two integers n,q 1≤n,q≤105), denoting the length of permutation P and the number of queries, respectively.
The second line contains n distinct integers p1,p2,…,pn 1≤pi≤n).
Each of the following q lines contains two integers 1≤li≤ri≤n), denoting the parameters for the i-th query.
1
10 5
3 7 9 2 6 4 5 8 10 1
1 10
2 6
7 9
4 9
3 3
2
1
0
1
0