You are given an array A of size N and Q queries. Now for each query of the form X, Y and K, output the Kth smallest number in sub-array between X and Y.
The first line contains integer T, denoting number of test cases. The first line of each test case contains an integer N & Q, denoting the number of elements in array A and number of query respectively. The second line of each test case contains N space separated integers denoting values of the array A. Third line of each test case contains Q queries in form X Y K.
For each test case, output Q integers in single line. where Ith integer is answer to Ith query.
1 <= T <= 20
1 <= N <= 15000
1 <= Q <= 10000
1 <= Aj <= N, 1 <= j <= N
4 1 2 2 3
1 5 2 3 5 3
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.