#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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];
    }

    int max_value = 0;

    for (int L = 0; L < N; ++L) {
        int xor_val = 0;
        int and_val = ~0;
        for (int R = L; R < N; ++R) {
            xor_val ^= A[R];
            and_val &= B[R];

            int value = xor_val * and_val;
            max_value = max(max_value, value);
        }
    }

    cout << max_value << endl;
    return 0;
}