#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long unsigned int n;
    cin>>n;
    vector<long long unsigned int> a(n);
    vector<long long unsigned int> b(n);
    for(long long unsigned int i=0;i<n;i++){
        cin>>a[i];
    }
    for(long long unsigned int i=0;i<n;i++){
        cin>>b[i];
    }
    long long unsigned int biggest = 0;
    for(long long unsigned int l=0;l<n-1;l++){
        for(long long unsigned int r=l+1;r<n;r++){
            long long unsigned int a_xor = a[l];
            for(long long unsigned int i=l+1;i<=r;i++){
                a_xor ^= a[i];
            }
            long long unsigned int b_and = b[l];
            for(long long unsigned int i=l+1;i<=r;i++){
                b_and &= b[i];
            }
            if(biggest < a_xor * b_and)
                biggest = a_xor * b_and;
        }
    }
    cout<<biggest;
}