eolymp
bolt
Try our new interface for solving problems
Problems

Maximal XOR

Maximal XOR

Given array of integers $a_1, a_2, ..., a_n$. For the given value of $x$ find such $a_i$ that $x~xor~a_i$ is maximum. \InputFile First line contains number $n~(n \le 10^5)$ and number of queries $q$. Second line contains integers $a_1, a_2, ..., a_n~(0 \le a_i \le 10^{18})$. Each of the next $q$ lines contains one number $x~(0 \le x \le 10^{18})$. \OutputFile For each value of $x$ print in a separate line such value $a_i$ that $x~xor~a_i$ is maximum.
Time limit 1 second
Memory limit 256 MiB
Input example #1
5 6
5 3 7 2 6
1
2
4
5
3
6
Output example #1
6
5
3
2
5
3