


The first line of input contains an integer ‘T’, denoting the number of test cases. Then the test cases follow.
The first line of each test case contains two space-separated integers, ‘N’ and ‘K’, denoting the number of boxes and the correct key number, respectively.
The second line of each test case contains ‘N’ space-separated integers denoting the key numbers in the array ‘key’.
For each test case, Print the box number which contains the correct key or ‘-1’ if the key is not present.
Print the output of each test case in a new line.
You are not required to print the expected output. It has already been taken care of. Just implement the function.
It is guaranteed that key[i] > key[j] for all i>j.
1<= T <= 10
1 <= N <= 10^4
1 <= K <= 10^9
1 <= key[i] <= 10^9
Where ’T’ is the number of test cases, ‘N’ is the number of boxes, ‘K’ is the correct key number, and 'key[i]' is the key number of the key in the ith box.
Time Limit: 1 sec
The idea here is to traverse the entire array ‘key’ linearly and find the box which contains the required key.
The steps are as follows:
As the given array ‘key’ is sorted, the idea is to use binary search instead of linear search. Suppose we have checked the ith box, and it contains a key number smaller than the required key number. Then it is not possible for the required key to be present in the jth box for j<i, since the list is sorted. Thus after checking the ith box, it is beneficial to check only in the range i+1 to N.
Thus, we can divide the array into two parts, check the middle element, and accordingly continue checking in the first half or second half.
The steps are as follows:
Similar to the binary search approach, we can now divide the list into three parts and check which half may contain the required key.
The steps are as follows: