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

using namespace std;

int main() {
    int c;
    cin >> c;
    vector<int> A(c), B(c);
    for (int i = 0; i < c; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < c; i++) {
        cin >> B[i];
    }
    long long maks = 0;
    for (int g = 0; g < c; g++) {
        int prsuma = 0; 
        int isuma = ~0;

        for (int b = g; b < c; b++) {
            prsuma ^= A[b]; 
            isuma &= B[b];
            long long trenutnavrednost = (long long) prsuma * isuma;
            maks = max(maks, trenutnavrednost); 
        }
    }
    cout << maks << endl;
}