The first line is an integer T which indicates the case number.
And as for each case, first line is two integer N and M which indicates the length of permutation and number of query.
Next line is N integer which indicate the permutation P
Next M line, for each line is two integer L and R which indicate each query.
Limit
$1 \leq T \leq 100$
$1 \leq N, M \leq100000$
$1 \leq Pi \leq N$, for any pair $(i, j)$, $Pi \neq Pj$
$1 \leq Li \leq Ri \leq N$
About 95% test case: $1 \leq N \leq 1000$
Other test case: $1 \leq N \leq 100000$