#include <bits/stdc++.h>

using namespace std;

int main(){

    int n; 
    cin >> n; 
    vector<long long> a(n); 
    vector<long long> b(n); 

    for (long long i = 0; i < n; i++) { 
        cin >> a[i]; 
    } 

    for (long long i = 0; i < n; i++) { 
        cin >> b[i]; 
    } 

    long long maxe = 0;  

    for (long long l = 0; l < n; l++) { 
        long long Suma = 0; 
        long long Proizvod = b[l]; 

        for (long long r = l; r < n; r++) { 
            Suma ^= a[r]; 
            Proizvod &= b[r]; 
            long long tr = Suma * Proizvod; 
            maxe = max(maxe, tr); 
            } 
        } 
        
        cout << maxe << endl;

    return 0;
}