#include <bits/stdc++.h>

using namespace std;

int main()
{
    std::ios_base::sync_with_stdio(false);
    unsigned long long n;
    cin >> n;
    vector<unsigned long long> a,b;

    for(unsigned long long i=0; i<n; i++)
    {
        unsigned long long p;
        cin >> p;
        a.push_back(p);
    }
    for(unsigned long long i=0; i<n; i++)
    {
        unsigned long long p;
        cin >> p;
        b.push_back(p);
    }

    unsigned long long mx=0;
    for(unsigned long long l=0; l<n-1; l++)
    {
        unsigned long long azbir=a[l],bzbir=b[l];
        for(unsigned long long r=l+1; r<n; r++)
        {
            azbir=azbir^a[r];
            bzbir=bzbir&b[r];
            mx=max(azbir*bzbir,mx);
        }
    }

    cout << mx << endl;
    return 0;
}