Problem of the day
1. If all integers are greater than ‘Ai’ in array/list ‘ARR’ then the answer to this ith query will be -1.
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case will contain two space-separated integers ‘N’ and ‘M’ representing the size of array/list ‘ARR’ and number of queries respectively.
The second line of each test case will contain ‘N’ space-separated integers representing array/list ‘ARR’.
The next ‘M’ line of each test case contains the description of ‘QUERIES’. The ‘i-th’ line of these ‘M’ lines consists of two space-separated integers ‘Xi’, ‘Ai’ as described in the problem statement.
For each test case, print ‘M’ space-separated integer where the ‘i-th’ integer is the answer of the ‘i-th’ query.
Output for every test case will be printed in a separate line.
You don’t need to print anything; It has already been taken care of.
1 <= T <= 50
1 <= N, M <= 10000
0 <= ARR[i], Xi, Ai <= 10^9
Where ‘T’ is the number of test cases, 'N' is the size of ‘ARR’, ‘M’ is the number of queries, ‘ARR[i]’ is an element of array/list ‘ARR’ and ‘Xi’, ‘Ai’ are the integers in ‘QUERIES[i]’.
Time limit: 1 sec
2
5 2
0 1 2 3 4
1 3
5 6
1 1
1
1 0
3 7
-1
In the first test case, the answer of query [1, 3] is 3 because 1^2 = 3 and 2 <= 3, and the answer of query [5, 6] is 7 because 5 ^ 2 = 7 and 2 <= 6.
In the second test case, no element is less than or equal to 0 in the given array ‘ARR’.
2
6 3
6 6 3 5 2 4
6 3
8 1
12 4
5 2
0 0 0 0 0
1 0
1 1
5 -1 15
1 1