You are given an array of length
. You repeatedly perform the following operation:
- Let the XOR of all elements in
be
. Select an integer
and replace
with
.
Your goal is to match with another array
. Determine if it is possible to achieve the goal, and the minimum number of operations required.
Input Specification
The first line will contain the
.
The second line will contain integers,
, the original array.
The third line will contain integers,
, the array you wish to achieve.
Output Specification
Output the minimum number of operations required. If it is impossible, output -1
.
Sample Input 1
3
0 1 2
3 1 0
Sample Output 1
2
Sample Input 2
3
0 1 2
0 1 2
Sample Output 2
0
Sample Input 3
2
1 1
0 0
Sample Output 3
-1
Sample Input 4
4
0 1 2 3
1 0 3 2
Sample Output 4
5
Comments