Xor

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

For given multisets \(A\) and \(B\), find minimum non-negative \(x\) which \(A \oplus x = B\).

Note that for \(A = \{a_1, a_2, \ldots, a_n\}\), \(A \oplus x = \{a_1 \oplus x, a_2 \oplus x, \ldots, a_n \oplus x\}\). \(\oplus\) stands for exclusive-or.

Input

The first line contains a integer \(n\), which denotes the size of set \(A\) (also for \(B\)).

The second line contains \(n\) integers \(a_1, a_2, \ldots, a_n\), which denote the set \(A\).

The thrid line contains \(n\) integers \(b_1, b_2, \ldots, b_n\), which denote the set \(B\).

(\(1 \leq n \leq 10^5\), \(n\) is odd, \(0 \leq a_i, b_i < 2^{30}\))

Output

The only integer denotes the minimum \(x\). Print \(-1\) if no such \(x\) exists.

Sample Input

3
0 1 3
1 2 3

Sample Output

2

Source

ftiasch

Manager

Information
Solved Number110
Submit Number237
Problem Tags
math
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel