#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#define N 100005
using namespace std;
int n,a[N],b[N],aa[N],bb[N],fa[N],cnt,ans;
bool vis[N<<1];
map<int,int>mp;
template<class T>inline void read(T &x) {
	register T s=0,g=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')g=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch^48);ch=getchar();}
	x=g?-s:s;
}
int getfa(int k){return fa[k]==k?k:fa[k]=getfa(fa[k]);}
int main() {
	read(n);
	for(register int i=1;i<=n;i=-~i)
		read(a[i]),a[n+1]^=a[i];
	for(register int i=1;i<=n;i=-~i)
		read(b[i]),b[n+1]^=b[i];
	++n;
	memcpy(aa,a,(n+1)<<2),memcpy(bb,b,(n+1)<<2);
	sort(aa+1,aa+n+1);sort(bb+1,bb+n+1);
	for(register int i=1;i<=n;i=-~i) {
		if(aa[i]!=bb[i]) {
			puts("-1");
			return 0;
		}
		if(!mp[aa[i]]) mp[aa[i]]=++cnt;
	}
	for(register int i=1;i<=cnt;i=-~i)
		fa[i]=i;
	for(register int i=1,f1,f2;i<=n;i=-~i) {
		a[i]=mp[a[i]],b[i]=mp[b[i]];
		if(a[i]!=b[i]) {
			ans+=i<n;
			f1=getfa(a[i]),f2=getfa(b[i]);
			if(f1!=f2) {
				fa[f1]=f2;
				vis[f1]=vis[f2]=true;
			}
		}
	}
	if(!ans) {
		puts("0");
		return 0;
	}
	vis[a[n]]=vis[b[n]]=true;
	for(register int i=1;i<=cnt;i=-~i)
		if(vis[i]&&getfa(i)==i) ++ans;
	printf("%d\n",ans-1);
	return 0;
}
### Prompt

Your task is to create 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
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#define N 100005
using namespace std;
int n,a[N],b[N],aa[N],bb[N],fa[N],cnt,ans;
bool vis[N<<1];
map<int,int>mp;
template<class T>inline void read(T &x) {
	register T s=0,g=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')g=1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch^48);ch=getchar();}
	x=g?-s:s;
}
int getfa(int k){return fa[k]==k?k:fa[k]=getfa(fa[k]);}
int main() {
	read(n);
	for(register int i=1;i<=n;i=-~i)
		read(a[i]),a[n+1]^=a[i];
	for(register int i=1;i<=n;i=-~i)
		read(b[i]),b[n+1]^=b[i];
	++n;
	memcpy(aa,a,(n+1)<<2),memcpy(bb,b,(n+1)<<2);
	sort(aa+1,aa+n+1);sort(bb+1,bb+n+1);
	for(register int i=1;i<=n;i=-~i) {
		if(aa[i]!=bb[i]) {
			puts("-1");
			return 0;
		}
		if(!mp[aa[i]]) mp[aa[i]]=++cnt;
	}
	for(register int i=1;i<=cnt;i=-~i)
		fa[i]=i;
	for(register int i=1,f1,f2;i<=n;i=-~i) {
		a[i]=mp[a[i]],b[i]=mp[b[i]];
		if(a[i]!=b[i]) {
			ans+=i<n;
			f1=getfa(a[i]),f2=getfa(b[i]);
			if(f1!=f2) {
				fa[f1]=f2;
				vis[f1]=vis[f2]=true;
			}
		}
	}
	if(!ans) {
		puts("0");
		return 0;
	}
	vis[a[n]]=vis[b[n]]=true;
	for(register int i=1;i<=cnt;i=-~i)
		if(vis[i]&&getfa(i)==i) ++ans;
	printf("%d\n",ans-1);
	return 0;
}
```