You are given an array of elements. A list of integers, is given as an input, find the maximum value of for all , where represents xor of two elements.
Note that there are multiple test cases in one input file.
For example:
Function Description
Complete the maxXor function in the editor below. It must return an array of integers, each representing the maximum xor value for each element against all elements of .
maxXor has the following parameter(s):
- arr: an array of integers
- queries: an array of integers to query
Input Format
The first line contains an integer , the size of the array .
The second line contains space-separated integers, from .
The third line contain , the size of the array .
Each of the next lines contains an integer where .
Constraints
Output Format
The output should contain lines with each line representing output for the corresponding input of the testcase.
Sample Input 0
3
0 1 2
3
3
7
2
Sample Output 0
3
7
3
Explanation 0
Sample Input 1
5
5 1 7 4 3
2
2
0
Sample Output 1
7
7
Explanation 1
Sample Input 2
4
1 3 5 7
2
17
6
Sample Output 2
22
7
Explanation 2