using namespace std;
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    unsigned int n = 0;
    cin >> n;
    vector<unsigned int> A(n);
    vector<unsigned int> B(n);
    unsigned int x;
    unsigned int L, R;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> B[i];
    }
    unsigned int prvi, drugi;
    int najveci;
    for (x = 0; x < n; ++x)
    {
        int bitA = 0;
        int bitB = -1;
        for (unsigned int i = x; i < n; ++i)
        {
            bitA ^= A[i];
            bitB &= B[i];
            int proizvod = bitB * bitA;
            najveci = max(najveci, proizvod);
        }
    }
    cout << najveci;
    return 0;
}