#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;

    int a[n], b[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 0; i < n; i++)
        cin >> b[i];

    int maxVr = 0;

    for (int l = 0; l < n; l++) {
        int xorVr = 0;
        int andVr = b[l];

        for (int r = l; r < n; r++) {
            xorVr ^= a[r];
            andVr &= b[r];

            int trenutnaVr = xorVr * andVr;
            maxVr = max(maxVr, trenutnaVr);
        }
    }

    cout << maxVr << endl;

    return 0;
}