using System;

class Program
{
    static long max(int N, int[] A, int[] B)
    {
        int[] a = new int[N + 1];

        for (int i = 1; i <= N; i++)
        {
            a[i] = a[i - 1] ^ A[i - 1];
        }

        long max = 0;
        int L = 0;

        while (L < N)
        {
            int c = B[L];
            int R = L;

            while (R < N && c > 0)
            {
                int b = a[R + 1] ^ a[L];
                c &= B[R];
                max = Math.Max(max, (long)b * c);
                R++;
            }
            L++;
        }

        return max;
    }

    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int[] B = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        long a = max(N, A, B);

        Console.WriteLine(a);
    }
}