#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 200001;
int A[MAX_N], B[MAX_N];
int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }
    for (int i = 1; i <= N; ++i) {
        cin >> B[i];
    }
    int MaxV = 0;
    for (int pocetak = 1; pocetak <= N; ++pocetak) {
        int XorV = 0;
        int AndV = -1;
        for (int kraj = pocetak; kraj <= N; ++kraj) {
            XorV ^= A[kraj];
            AndV &= B[kraj];
            MaxV = max(MaxV, XorV * AndV);
        }
    }
    cout << MaxV << endl;
    return 0;
}