#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> b[i];
    }

    long long maks = 0;
    for(int levo = 0; levo < n; levo++) {
        int trxor = 0;
        int trand = INT_MAX;
        for(int desno = levo; desno < n; desno++) {
            trxor ^= a[desno];
            trand &= b[desno];
            maks = max(maks, (long long)(trxor * trand));
        }
    }

    cout << maks << "\n";
    return 0;
}