402794: GYM100883 E xortion

Memory Limit:128 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. xortiontime limit per test3 secondsmemory limit per test128 megabytesinputstandard inputoutputstandard output

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.

Input

The 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.

Output

For each testcase output Q lines . The Ith line will contain the answer of the Ith query.

Separate testcases by a blank line .

ExamplesInput
1
3 3
3 1 2
4
5
6
Output
1
3
2

Note

Use fast I/O methods

加入题单

上一题 下一题 算法标签: