#include <iostream>
#include <algorithm>

using namespace std;

const int MAX_N = 200000;

int main() {
    int N;
    cin >> N;

    int A[MAX_N], B[MAX_N];

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }

    long long maxValue = 0;


    for (int l = 0; l < N; l++) {
        int D = 0;
        int F = B[l];

        for (int r = l; r < N; r++) {
            D ^= A[r];
            F &= B[r];

            long long value = (long long) D * F;
            maxValue = max(maxValue, value);
        }
    }

    cout << maxValue << endl;

    return 0;
}