#include <iostream>
#include <bitset>
#include <climits>
#include <vector>
using namespace std;

int main()
{
    unsigned int N;
    do{
        cin >> N;
    }while(N < 1 || N > 2e5);
    vector<unsigned long long int> A(N), B(N);
    for(int i = 0; i < N; i++){
        do{
            cin >> A[i];
        }while(A[i] < 0 || A[i] > 1e10);
    }
    for(int i = 0; i < N; i++){
        do{
            cin >> B[i];
        }while(A[i] < 0 || A[i] > 1e10);
    }
    unsigned long long int maksimumA = A[0], maksimumB = B[0], pom = 0;
    for(int i = 0; i < N; i++){
        for(int l = 0; l < N - i; l++){
            for(int j = 0; j <= i; j++){
                pom = A[l + j] ^ pom;
            }
            if(pom > maksimumA)
                maksimumA = pom;
            pom = 0;
        }
    }
    pom = ULLONG_MAX;
    for(int i = 0; i < N; i++){
        for(int l = 0; l < N - i; l++){
            for(int j = 0; j <= i; j++){
                pom = B[l + j] & pom;
            }
            if(pom > maksimumB)
                maksimumB = pom;
            pom = ULLONG_MAX;
        }
    }
    cout << maksimumA * maksimumB;
}