//BAGHER
//hame chi sefid o siah e engar ye omre shabe
#include <bits/stdc++.h>
using namespace std;

const int maxn = 4e5 + 12;
int n, a[maxn], b[maxn], cnt[maxn];
vector <int> cmp, ad[maxn];
int val, ans = -1;
bool ch[maxn];

void dfs(int root) {
	ch[root] = 1;
	for (int i : ad[root])
		if (!ch[i])
			dfs(i);
	return;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		val = (val ^ a[i]);
		cmp.push_back(a[i]);
	}
	cmp.push_back(val);
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		cmp.push_back(b[i]);
	}
	sort(cmp.begin(), cmp.end());
	cmp.resize(unique(cmp.begin(), cmp.end()) - cmp.begin());

	for (int i = 0; i < n; i++) {
		a[i] = lower_bound(cmp.begin(), cmp.end(), a[i]) - cmp.begin();
		cnt[a[i]]++;
		b[i] = lower_bound(cmp.begin(), cmp.end(), b[i]) - cmp.begin();
	}
	val = lower_bound(cmp.begin(), cmp.end(), val) - cmp.begin();
	cnt[val]++;
	for (int i = 0; i < n; i++) {
		cnt[b[i]]--;
		if (cnt[b[i]] < 0)
			return cout << -1, 0;
		if (a[i] == b[i])
			continue;
		ad[a[i]].push_back(b[i]);
		ad[b[i]].push_back(a[i]);
		ans++;
	}
	for (int i = 0; i <= n; i++) {
		if (!ch[i]) {
			if (ad[i].size() || i == val) {
				dfs(i); ans++;
			}
		}
	}
	cout << ans;

	return 0;
}


### Prompt

Please formulate a Cpp solution to the following problem:

There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a non-negative integer.

Snuke can repeatedly perform the following operation:

* Let the XOR of all the elements in a be x. Select an integer i (1 ≤ i ≤ N) and replace a_i with x.



Snuke's objective is to match a with another sequence b = (b_1, b_2, ..., b_N). Here, each b_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

* 2 ≤ N ≤ 10^5
* a_i and b_i are integers.
* 0 ≤ a_i, b_i < 2^{30}

Input

Input is given from Standard Input in the following format:


N
a_1 a_2 ... a_N
b_1 b_2 ... b_N


Output

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

Examples

Input

3
0 1 2
3 1 0


Output

2


Input

3
0 1 2
0 1 2


Output

0


Input

2
1 1
0 0


Output

-1


Input

4
0 1 2 3
1 0 3 2


Output

5

### Response

```cpp
//BAGHER
//hame chi sefid o siah e engar ye omre shabe
#include <bits/stdc++.h>
using namespace std;

const int maxn = 4e5 + 12;
int n, a[maxn], b[maxn], cnt[maxn];
vector <int> cmp, ad[maxn];
int val, ans = -1;
bool ch[maxn];

void dfs(int root) {
	ch[root] = 1;
	for (int i : ad[root])
		if (!ch[i])
			dfs(i);
	return;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		val = (val ^ a[i]);
		cmp.push_back(a[i]);
	}
	cmp.push_back(val);
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		cmp.push_back(b[i]);
	}
	sort(cmp.begin(), cmp.end());
	cmp.resize(unique(cmp.begin(), cmp.end()) - cmp.begin());

	for (int i = 0; i < n; i++) {
		a[i] = lower_bound(cmp.begin(), cmp.end(), a[i]) - cmp.begin();
		cnt[a[i]]++;
		b[i] = lower_bound(cmp.begin(), cmp.end(), b[i]) - cmp.begin();
	}
	val = lower_bound(cmp.begin(), cmp.end(), val) - cmp.begin();
	cnt[val]++;
	for (int i = 0; i < n; i++) {
		cnt[b[i]]--;
		if (cnt[b[i]] < 0)
			return cout << -1, 0;
		if (a[i] == b[i])
			continue;
		ad[a[i]].push_back(b[i]);
		ad[b[i]].push_back(a[i]);
		ans++;
	}
	for (int i = 0; i <= n; i++) {
		if (!ch[i]) {
			if (ad[i].size() || i == val) {
				dfs(i); ans++;
			}
		}
	}
	cout << ans;

	return 0;
}


```