402794: GYM100883 E xortion
Description
Hussain doesn't like long statements’ problems, so he will describe his problem in a nutshell.
Hussain will give you an array A[1….N] that consists of N positive integers.
Hussain will ask you Q Queries each one consists of an integer number X .
He wants you to find a number P : 1 ≤ P ≤ N such that (A[P]^X ≥ A[I]^X ) for each (1 ≤ I ≤ N).
^ Refers to “XOR” operation in computer science .
In case of many possible values of P , take the minimum.
InputThe first line contains one number T – the number of testcases.
The second line contains two space-separated numbers, N and Q (1 ≤ N ≤ 105, 1 ≤ Q ≤ 3×105) — the size of the array and the number of queries .
The next line contains N space-separated integers the elements of the array A . All of them will fit into 32 bit signed integer.
Next Q lines contain one integer X (also fits in 32 bit signed integer) which was described above.
OutputFor each testcase output Q lines . The Ith line will contain the answer of the Ith query.
Separate testcases by a blank line .
ExamplesInput1Output
3 3
3 1 2
4
5
6
1Note
3
2
Use fast I/O methods