#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 400000

vector<int>e[N];
bool used[N];
int s;

void dfs(int k){
used[k]=true;
s++;
f(i,e[k].size()){
if(!used[e[k][i]]){
dfs(e[k][i]);
}
}
return;
}




int main(){
map<int,int>m;
set<int>st;
	vector<int>a;
vector<int>b;
	vector<int>c;
vector<int>d;
	int n, k;
	int x, y, z;
	int ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
y=0;
k=0;
	f(i,n){
		scanf("%d", &x);
if((st.insert(x)).second){
m[x]=k;
k++;
}
y=y^x;
		a.push_back(x);
		c.push_back(x);
	}
if((st.insert(y)).second){
m[y]=k;
k++;
}
		a.push_back(y);
		c.push_back(y);
z=y;
y=0;
	f(i,n){
		scanf("%d", &x);
		b.push_back(x);
		d.push_back(x);
if(a[i]!=b[i])ans++;
y=y^x;
	}
		b.push_back(y);
		d.push_back(y);
sort(a.begin(),a.end());
sort(b.begin(),b.end());

	f(i,n+1){
if(a[i]!=b[i])v=false;
	}
if(!v){
printf("-1\n");
return 0;
}

f(i,n+1){
e[m[c[i]]].push_back(m[d[i]]);
e[m[d[i]]].push_back(m[c[i]]);
}
f(i,k)used[i]=false;


f(i,k){
if(!used[i]){
s=0;
v=used[m[z]];
dfs(i);
if(s>1){
if(v==used[m[z]])ans++;
}
}
}



	printf("%d\n", ans);


	return 0;
}
### Prompt

In CPP, your task is to solve 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
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 400000

vector<int>e[N];
bool used[N];
int s;

void dfs(int k){
used[k]=true;
s++;
f(i,e[k].size()){
if(!used[e[k][i]]){
dfs(e[k][i]);
}
}
return;
}




int main(){
map<int,int>m;
set<int>st;
	vector<int>a;
vector<int>b;
	vector<int>c;
vector<int>d;
	int n, k;
	int x, y, z;
	int ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
y=0;
k=0;
	f(i,n){
		scanf("%d", &x);
if((st.insert(x)).second){
m[x]=k;
k++;
}
y=y^x;
		a.push_back(x);
		c.push_back(x);
	}
if((st.insert(y)).second){
m[y]=k;
k++;
}
		a.push_back(y);
		c.push_back(y);
z=y;
y=0;
	f(i,n){
		scanf("%d", &x);
		b.push_back(x);
		d.push_back(x);
if(a[i]!=b[i])ans++;
y=y^x;
	}
		b.push_back(y);
		d.push_back(y);
sort(a.begin(),a.end());
sort(b.begin(),b.end());

	f(i,n+1){
if(a[i]!=b[i])v=false;
	}
if(!v){
printf("-1\n");
return 0;
}

f(i,n+1){
e[m[c[i]]].push_back(m[d[i]]);
e[m[d[i]]].push_back(m[c[i]]);
}
f(i,k)used[i]=false;


f(i,k){
if(!used[i]){
s=0;
v=used[m[z]];
dfs(i);
if(s>1){
if(v==used[m[z]])ans++;
}
}
}



	printf("%d\n", ans);


	return 0;
}
```