2325: Keyboard
题目描述
Recently ,a BUCT ACMer Luo is crazy for a keyboard.But he has no money. But now something different happens.The seller makes some activities,and the customer who wins the game can select a good and buy it with 1% price.
The game is:There are N different numbers. Now he gives you M queries.Each queries has a number x and you have to choose a number from them which has the maximum XOR with the x(0<=x<=2^32) The XOR is an operation,which outputs true when both inputs are different.
For example :
1 XOR 1=0,0 XOR 0=0,1 XOR 0=1,0 XOR 1 =1,3 XOR 5= 011(2) XOR 101(2) =110(2) =6 in C/C++ ,^ means XOR.
输入
The first line has a number T,and it has T cases followed.For each case,there are 2 numbers N and M in the first line(1<=N,M<=100000)
Then there is a line contains N numbers .After that M numbers followed which is the queries.
输出
For each case,output "Case #?",in the first line.Then M lines,each line is the answer of a querie.
样例输入 复制
2
3 2
3 4 5
1
5
4 1
4 6 5 6
3
样例输出 复制
Case #1:
4
3
Case #2:
4