XOR
면접 대비시간 제한4초메모리 제한1024 MB
서로 다른 수들의 집합과 여러 질의가 주어질 때, 각 질의에 대해 질의와 XOR한 값이 가장 큰 집합 원소를 출력한다.
문제
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 , , 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 .
Paul and Andrew liked this operation so much that they invented a game. First, Paul writes integer numbers . Second, Andrew writes integers . After that, Paul finds for each such that XOR 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 () --- how many numbers Paul wrote. The second line contains Paul's numbers (). All are different.
The third line contains an integer () --- how many numbers Andrew wrote. The fourth line contains Andrew's numbers ().
출력
Output numbers: for each , output such that XOR is maximal.