DOS is a new single-pla
In each "matching" operation you can choose any two cards (we assume that the subsc
Kayzin will ask you mm times. In the k-th query, you need to select four cards from the cards with subsc
Note that the queries are independent of each other.
The first line contains an integer T(T≤100). Then T test cases follow. For one case,
The first line contains two integer (4≤n≤2×105) and m (1≤m≤10^5) , nn denotes the total number of cards , mm denotes the number of times Kayzin queries.
The second line contains n integers a1,a2,…,an (1≤ai≤10^8), denotes the value of each card.
The next mm lines contain Kayzin's queries. The kth line has two numbers, Lk and Rk (1≤Lk≤Rk≤n), the input guarantees that Rk−Lk≥3.
It is guaranteed that the sum of n over all test cases doesn't exceed 2×10^5 and the sum of m over all test cases doesn't exceed 2×10^5.
1
5 3
5 3 2 8 4
1 5
1 4
2 5
69
-34
53