AQT has two multisets of integers and , both of size for some non-negative integer . Help AQT determine the smallest non-negative integer such that after XOR-ing each element in by , the multisets and are equal.
Constraints
In all subtasks,
Subtask 1 [5%]
Subtask 2 [15%]
Subtask 3 [80%]
No additional constraints.
Input Specification
The first line contains one integer .
The second line contains space separated integers, .
The third line contains space separated integers, .
Output Specification
Output the smallest possible value of as described above on a single line. If no such value exists, output -1
on a single line.
Sample Input 1
3
84 80 88 84 93 84 86
5 1 12 7 9 5 5
Sample Output 1
81
Explanation of Sample Output 1
The smallest possible solution is . If we XOR each element in by , we have , which is equivalent to .
Sample Input 2
1
3 1 9
1 12 123
Sample Output 2
-1
Comments