#include <iostream>
#include <bits/stdc++.h>

using namespace std;
void unos(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    int b[n];
    unos(a,n);
    unos(b,n);
    int s = 0;
    int maxi = 0;
    for(int r = 0; r < n; r++)
    {
        int suma_xor = 0;
        int suma_and = 1;
        for(int l = r; l < n; l++)
        {
            suma_xor = suma_xor ^ a[l];
            suma_and = suma_and & b[l];
        }
        s = suma_xor * suma_and;
        if(s > maxi)
            maxi = s;
    }

    cout << maxi;
    return 0;
}