#include<bits/stdc++.h>
using namespace std;
#define int long long
int ming[1000005];
int an[1000005];
signed main(){
freopen("XORcipher.in","r",stdin);
freopen("XORcipher.out","w",stdout);
int n;
cin>>n;
int maxx=0;
string a="";
for(int i = 1;i<=n;i++){
scanf("%lld",&ming[i]);
maxx=max(maxx,ming[i]);
}
for(int i = 1;i<=n;i++){
scanf("%lld",&an[i]);
maxx=max(maxx,an[i]);
}
int r=0;
while(maxx!=0){
maxx/=2;
r++;
}
for(int i = 0;i<r;i++){
int yi1=0,yi2=0;
for(int j = 1;j<=n;j++){
if((ming[j]>>i)%2==1)yi1++;
if((an[j]>>i)%2==1)yi2++;
}
if(yi1==yi2){
a=a+"0";
}
else a=a+"1";
}
//cout<<a;
int ans=0;
int w=1;
for(int i = 0;i<r;i++){
if(a[i]=='1')ans+=w;
w*=2;
}
printf("%lld",ans);
return 0;
}