#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, a[1000010], b[1000010], ans, numa[2][1000], numb[2][1000], maxn;
map<int, int> id;
signed main() {
freopen("XORcipher.in", "r", stdin);
freopen("XORcipher.out", "w", stdout);
cin >> n;
for(int i = 1; i <= n; i ++) {
cin >> a[i];
int x = 0;
int w = a[i];
while(w) {
maxn = max(maxn, x);
numa[w % 2][x] ++;
x ++;
w /= 2;
}
}
for(int i = 1; i <= n; i ++) {
cin >> b[i];
int x = 0;
int w = b[i];
while(w) {
maxn = max(maxn, x);
numb[w % 2][x] ++;
x ++;
w /= 2;
}
}
// ans = 1;
for(int i = maxn; i >= 0; i --) {
ans *= 2;
if(numa[1][i] != numb[1][i]) {
ans += 1;
}
}
cout << ans;
return 0;
}