using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split();
        string[] st = Console.ReadLine().Split();
        int[] a = new int[n];
        int[] b = new int[n];
        int A = 0;
        int B = 1;
        int s = 0;
        int maxs = 0;
        for (int i = 0; i < n; i++)
            a[i] = int.Parse(str[i]);
        for (int i = 0; i < n; i++)
            b[i] = int.Parse(st[i]);
        for (int l = 0; l < n; l++)
        {
            A = 0;
            B = 1;
            for (int d = l; d < n; d++)
            {
                A ^= a[d];
                B &= b[d];
                s = A * B;
                if (s > maxs)
                    maxs = s;  
            }
        }
        Console.WriteLine(maxs);

        Console.ReadLine();
    }
}