The first line contains the number of test cases $T(1 \leq T \leq 10)$.
For each test case,there are two integers $n, m(0 < n, m \leq 30000)$ in the first line.N is the number of girls,and M is the number of times that NPY want to visit his girls.
The following single line contains N integers, $a_1, a_2, a_3, \ldots , a_n$, which indicates the class number of each girl. $(0 < a_i \leq 30000)$
The following m lines,each line contains two integers $l, r(1 \leq l \leq r \leq n)$,which indicates the interval NPY wants to visit.