#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=1e5+5;
int n,a[N],b[N];
map<int,int> ok,cb,fa,exi;
int getfa(int x){return fa[x]?fa[x]=getfa(fa[x]):x;}
int main()
{
	n=read();
	int x=0;
	fo(i,1,n) a[i]=read(),x^=a[i];
	a[0]=x;
	x=0;
	fo(i,1,n) b[i]=read(),x^=b[i];
	b[0]=x;
	fo(i,0,n) ok[a[i]]++,cb[b[i]]++;
											bool same=1;
											fo(i,1,n) if(a[i]!=b[i]) same=0;
											if(same) return puts("0"),0;
	fo(i,0,n)
		if(ok[a[i]]!=cb[a[i]]) return puts("-1"),0;
	int ans=0;
	fo(i,0,n) if(a[i]!=b[i])
	{
		exi[a[i]]=1;
		if(i) ++ans;
		int f1=getfa(a[i]),f2=getfa(b[i]);
		if(f1!=f2) fa[f2]=f1;
	}
	fo(i,0,n) if(exi[a[i]] && getfa(a[i])==a[i]) ++ans,exi[a[i]]=0;
	if(!(a[0]==b[0] && ok[a[0]]==1)) --ans;
	printf("%d",ans);
	return 0;
}
### Prompt

Create a solution in Cpp for 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<cstring>
#include<algorithm>
#include<map>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=1e5+5;
int n,a[N],b[N];
map<int,int> ok,cb,fa,exi;
int getfa(int x){return fa[x]?fa[x]=getfa(fa[x]):x;}
int main()
{
	n=read();
	int x=0;
	fo(i,1,n) a[i]=read(),x^=a[i];
	a[0]=x;
	x=0;
	fo(i,1,n) b[i]=read(),x^=b[i];
	b[0]=x;
	fo(i,0,n) ok[a[i]]++,cb[b[i]]++;
											bool same=1;
											fo(i,1,n) if(a[i]!=b[i]) same=0;
											if(same) return puts("0"),0;
	fo(i,0,n)
		if(ok[a[i]]!=cb[a[i]]) return puts("-1"),0;
	int ans=0;
	fo(i,0,n) if(a[i]!=b[i])
	{
		exi[a[i]]=1;
		if(i) ++ans;
		int f1=getfa(a[i]),f2=getfa(b[i]);
		if(f1!=f2) fa[f2]=f1;
	}
	fo(i,0,n) if(exi[a[i]] && getfa(a[i])==a[i]) ++ans,exi[a[i]]=0;
	if(!(a[0]==b[0] && ok[a[0]]==1)) --ans;
	printf("%d",ans);
	return 0;
}
```