#agc016d. [agc016_d]XOR Replace

[agc016_d]XOR Replace

Problem Statement

There is a sequence of length NN: a=(a1,a2,...,aN)a = (a_1, a_2, ..., a_N). Here, each aia_i is a non-negative integer.

Snuke can repeatedly perform the following operation:

  • Let the XOR of all the elements in aa be xx. Select an integer ii (1iN1 ≤ i ≤ N) and replace aia_i with xx.

Snuke's objective is to match aa with another sequence b=(b1,b2,...,bN)b = (b_1, b_2, ..., b_N). Here, each bib_i is a non-negative integer.

Determine whether the objective is achievable, and find the minimum necessary number of operations if the answer is positive.

Constraints

  • 2N1052 ≤ N ≤ 10^5
  • aia_i and bib_i are integers.
  • 0ai,bi<2300 ≤ a_i, b_i < 2^{30}

Input

Input is given from Standard Input in the following format:

NN a1a_1 a2a_2 ...... aNa_N b1b_1 b2b_2 ...... bNb_N

Output

If the objective is achievable, print the minimum necessary number of operations. Otherwise, print -1 instead.


Sample Input 1

3
0 1 2
3 1 0

Sample Output 1

2

At first, the XOR of all the elements of aa is 33. If we replace a1a_1 with 33, aa becomes (3,1,2)(3, 1, 2).

Now, the XOR of all the elements of aa is 00. If we replace a3a_3 with 00, aa becomes (3,1,0)(3, 1, 0), which matches bb.


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