#include <iostream>

using namespace std;

long long racunaje(long long niza[], long long nizb[], long long l, long long r) {
    long long a = niza[l], b = nizb[l];
    for(long long i = l+1; i <= r; i++) a = (a^niza[i]);
    for(long long i = l+1; i <= r; i++) b = (b&nizb[i]);
    return a*b;
}

int main() {
    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];
   
    for(long long i = 0; i < n; i++) {
        for(long long j = i; j < n; j++) {
            temp = racunaje(a, b, i, j);
            if(r < temp) r = temp;
        }
    }
    cout << r;

    return 0;
}