| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 4 초 | 1024 MB | 54 | 37 | 33 | 89.189% |
Today Paul and Andrew discovered a new operation, XOR of two numbers.
Let us remind you that XOR, or exclusive OR, is a binary operation which is applied to two integer numbers bitwise. For each bit position, if the bits in the arguments are equal, the resulting bit is 0, otherwise 1. For example, 3 XOR 5 $=$ 6, because 3ドル_{10} = 011_2,ドル 5ドル_{10} = 101_2,ドル so if we apply the operation, the second and the third bits are set to 1, bit the first bit is set to 0, so we get 110ドル_{2} = 6_{10}$.
Paul and Andrew liked this operation so much that they invented a game. First, Paul writes $n$ integer numbers $a_i$. Second, Andrew writes $m$ integers $b_j$. After that, Paul finds for each $b_j$ such $k$ that $a_k$ XOR $b_j$ is maximal.
The only problem is that Paul is not very fast in finding these numbers. Help him!
The first line of the input contains one integer $n$ (1ドル \le n \le 100,000$) --- how many numbers Paul wrote. The second line contains Paul's numbers $a_i$ (0ドル \le a_i \le 10^9$). All $a_i$ are different.
The third line contains an integer $m$ (1ドル \le m \le 100,000$) --- how many numbers Andrew wrote. The fourth line contains Andrew's numbers $b_j$ (0ドル \le b_j \le 10^9$).
Output $m$ numbers: for each $b_j,ドル output such $a_k$ that $a_k$ XOR $b_j$ is maximal.
2 0 1 2 2 3
1 0
2 3 0 3 2 3 9
0 0 3