#include <iostream>

using namespace std;

long long racunanjeA(long long p, long long niz[], long long l, long long r) {
    if(r==l) return p;
    else return (niz[r]^racunanjeA(p, niz, l, r-1));
}
long long racunanjeB(long long p, long long niz[], long long l, long long r) {
    if(r==l) return p;
    else return (niz[r]&racunanjeB(p, niz, l, r-1));
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long long n, r = 0, temp;
    cin >> n;
    long long a[n], b[n];
    for(long long i = 0; i < n; i++) cin >> a[i];
    for(long long i = 0; i < n; i++) cin >> b[i];
   
    long long prefA[n], prefB[n];
    prefA[0] = a[0];
    prefB[0] = b[0];
    for(int i = 1; i < n; i++) prefA[i] = (a[i]^a[i-1]);
    for(int i = 1; i < n; i++) prefB[i] = (b[i]&b[i-1]);

    for(int i = 0; i < n; i++) {
        for(int j = i; j < n; j++) {
            r = max(r, (racunanjeA(a[i], a, i, j))*(racunanjeB(b[i], b, i, j)));
        }
    }

    cout << r;

    return 0;
}