using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] s1 = Console.ReadLine().Split();
        string[] s2 = Console.ReadLine().Split();

        int[] a = new int[n];
        int[] b = new int[n];

        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(s1[i]);
            b[i] = int.Parse(s2[i]);
        }

        int max = 0;

        for (int i = 0; i < n; i++)
        {
            int x = 0;
            int y = ~0;
            for (int j = i; j < n; j++)
            {
                x ^= a[j];
                y &= b[j];
                int tr = x * y;
                if (tr > max)
                {
                    max = tr;
                }
            }
        }

        Console.WriteLine(max);
    }
}