There are n bus stations and n bus lines along the main street of City A. The bus stations are labeled from 1 to n from left to right, and the importance of station i is a_i. The bus lines are also numbered from 1 to n. A bus of line k stops at stations whose importance is greater than or equal to k. Each bus line operates in both directions.
A tourist standing at station x can take any bus that stops at station x, pick a direction, and go to the next station y visited by that bus in that direction (of course, it is only possible if such station exists). The cost of such trip is l_x yuan if y<x, or r_x yuan if y>x. Tourists can take multiple bus trips to reach their destination.
Now there are q tourists, and the j-th tourist wants to travel from station s_j to station t_j. Your task is to find the minimum cost of the route for each tourist.
It is guaranteed that, for each i from 1 to n−1, the following are true: l_i≤l_i+1 and r_i≥r_i+1.
The first line of input contains a single integer T, the number of test cases (1≤T≤3⋅104). The descriptions of test cases follow.
The first line of each test case contains two integers n and q: the number of stations and the number of tourists (1≤n,q≤3⋅105).
The second line contains n integers a_1,…,a_n, where a_i is the importance of station i (1≤a_i≤n).
Then follow n lines, the i-th of which contains two integers l_i and r_i: the costs at station i (1≤l_i,r_i≤109, l_i≤l_i+1, r_i≥r_i+1).
Then follow q lines, the j-th of which contains two integers s_j and t_j: the endpoints of a route for j-th tourist (1≤s_j,t_j≤n).
The sum of n and the sum of q over all test cases do not exceed 3⋅105.
For each tourist, output a line with the answer.