#include <bits/stdc++.h>

using namespace std;

int upitA(int l, int r, const vector<int>& stablo, int n) {
        l += n;
        r += n;
        int levo = 0, desno = 0;
        while (l <= r) {
            if (l % 2 == 1) {
                levo = levo ^ stablo[l];
                l++;
            }
            if (r % 2 == 0) {
                desno = desno ^ stablo[r];
                r--;
            }
            l /= 2;
            r /= 2;
        }
        return levo ^ desno;
    }
unsigned upitB(int l, int r, const vector<unsigned>& stablo, int n) {
        l += n;
        r += n;
        unsigned levo = (1U << 31) - 1; unsigned desno = (1U << 31) - 1;
        while (l <= r) {
            if (l % 2 == 1) {
                levo = levo & stablo[l];
                l++;
            }
            if (r % 2 == 0) {
                desno = desno & stablo[r];
                r--;
            }
            l /= 2;
            r /= 2;
        }
        return levo & desno;
    }



int main() {
    int n;
    cin >> n;
    
    vector<int> A(n), B(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> B[i];
    }
    
    vector<int> stabloA;
    stabloA.resize(2 * n, 0);
    for (int i = 0; i < n; i++) {
        stabloA[n + i] = A[i];
    }
    for (int i = n - 1; i > 0; i--) {
        stabloA[i] = stabloA[2 * i] ^ stabloA[2 * i + 1];
    }

    vector<unsigned> stabloB;
    stabloB.resize(2 * n, (1U << 31) - 1);
    for (int i = 0; i < n; i++) {
        stabloB[n + i] = B[i];
    }
    for (int i = n - 1; i > 0; i--) {
        stabloB[i] = stabloB[2 * i] & stabloB[2 * i + 1];
    }
    
    long long maks = 0;

    for (int L = 0; L < n; L++) {
        
        for (int R = L; R < n; R++) {
            
            int ili = upitA(L, R, stabloA, n);
            int iii = upitB(L, R, stabloB, n);

            long long t = ili * iii;
            
            maks = max(t, maks);
        }
    }

    cout << maks << '\n';

    return 0;
}