#include <stdio.h>
#include <stdlib.h>

int main() 
{
    long long n;
    scanf("%lld", &n);
    long long A[n], B[n];
    for (long long i = 0; i < n; i++) 
    {
        scanf("%lld", &A[i]);
    }
    for (long long i = 0; i < n; i++) 
    {
        scanf("%lld", &B[i]);
    }
    long long max = 0;
    for (long long l = 0; l < n; l++) 
    {
        long long a1 = 0;    
        long long b1 = ~0;   
        for (long long r = l; r < n; r++) 
        {
            a1 ^= A[r];  
            b1 &= B[r]; 
            long long pom = a1 * b1;
            if (pom > max) 
            {
                max = pom;
            }
        }
    }
    printf("%lld\n", max);
    
    return 0;
}