#include<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
inline int read(){
	int n=0,f=1;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if (c=='-') c=getchar(),f=-1;
	for(;c>='0'&&c<='9';c=getchar()) n=n*10+c-48;
	return n*f;
}
const int maxn=1e5+5;
int i,j,n,a[maxn],b[maxn],x,ans;bool p;
int f[maxn],cnt;bool bz[maxn];
map<int,int>d;
map<int,int>c;
int get(int x){return (f[x])?f[x]=get(f[x]):x;}
void hb(int x,int y){
	x=get(d[x]),y=get(d[y]);
	if (x!=y) f[x]=y;
}
int main(){
	n=read();
	fo(i,1,n) x^=(a[i]=read()),c[a[i]]++;
	c[x]++;
	fo(i,1,n) {
		b[i]=read();
		if (!d[b[i]]) d[b[i]]=++cnt;
		if (c[b[i]]) c[b[i]]--;else return puts("-1"),0;
	}
	fo(i,1,n) if (a[i]!=b[i]) hb(a[i],b[i]),p|=b[i]==x,ans++;
	fo(i,1,n) if (a[i]!=b[i]) ans+=!bz[get(d[a[i]])],bz[get(d[a[i]])]=1;
	printf("%d\n",ans-p);
}
### Prompt

Develop a solution in cpp to the problem described below:

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<bits/stdc++.h> 
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
typedef long long ll;
using namespace std;
inline int read(){
	int n=0,f=1;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if (c=='-') c=getchar(),f=-1;
	for(;c>='0'&&c<='9';c=getchar()) n=n*10+c-48;
	return n*f;
}
const int maxn=1e5+5;
int i,j,n,a[maxn],b[maxn],x,ans;bool p;
int f[maxn],cnt;bool bz[maxn];
map<int,int>d;
map<int,int>c;
int get(int x){return (f[x])?f[x]=get(f[x]):x;}
void hb(int x,int y){
	x=get(d[x]),y=get(d[y]);
	if (x!=y) f[x]=y;
}
int main(){
	n=read();
	fo(i,1,n) x^=(a[i]=read()),c[a[i]]++;
	c[x]++;
	fo(i,1,n) {
		b[i]=read();
		if (!d[b[i]]) d[b[i]]=++cnt;
		if (c[b[i]]) c[b[i]]--;else return puts("-1"),0;
	}
	fo(i,1,n) if (a[i]!=b[i]) hb(a[i],b[i]),p|=b[i]==x,ans++;
	fo(i,1,n) if (a[i]!=b[i]) ans+=!bz[get(d[a[i]])],bz[get(d[a[i]])]=1;
	printf("%d\n",ans-p);
}
```