#include <iostream>
using namespace std;


int main() {
    int n;
    scanf("%d", &n);
    
    int a[n], b[n];
    int dp1[n][n], dp2[n][n];
    
    for(int i = 0;i<n;i++){
        scanf("%d", &a[i]);
    }
    
    for(int i = 0;i<n;i++){
        scanf("%d", &b[i]);
    }
    
    for(int i = 0; i<n;i++){
        dp1[i][i] = a[i];
        dp2[i][i] = b[i];
        for(int j = 0; j<i;j++){
            dp1[i][j] = dp1[i][j-1] ^ a[j];
            dp2[i][j] = dp2[i][j-1] & b[j];
        }
    }
    
    int mx = 0;
    for(int i =0;i<n;i++){
        for(int j =i;j<n;j++){
            if(dp1[i][j]*dp2[i][j] > mx){
                mx  = dp1[i][j]*dp2[i][j];
            }
        }
    }
    printf("%d", mx);
    return 0;
}