#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1000010, L = 40;
int n, a[N], b[N], c[L], d[L], ans;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
freopen("XORcipher.in", "r", stdin);
freopen("XORcipher.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) cin >> b[i];
for (int i = 0; i < L; i++) {
for (int j = 1; j <= n; j++) {
if (a[j]&(1ll<<i)) c[i]++;
if (b[j]&(1ll<<i)) d[i]++;
}
}
for (int i = 0; i < L; i++) ans += ((c[i]!=d[i])<<i);
cout << ans;
return 0;
}