#include <cstdio>
#include <iostream>
#include <map>
using namespace std;
constexpr int N = 114514;
int n;
long long a[N];
bool c[N];
long long res;
int main () {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
long long b;
for (int i = 1; i <= n; i++) {
cin >> b;
res ^= b;
a[i] ^= b;
}
for (int i = 1; i <= n; i++) {
cin >> c[i];
}
for (int i = 59; i >= 0; i--) {
long long x = 0;
long long y = 0;
for (int j = n; j >= 1; j--) {
if (a[j] & (1ll << i)) {
a[j] ^= (x ? x : (y = c[j], x = a[j]));
}
res ^= (((res >> i & 1)) ^ y) * x;
}
}
cout << res << endl;
return 0;
}