using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();

        long maxvred = long.MinValue;
        bool svi1 = b.All(x => x == 1);

        for (int l = 0; l < n; l++)
        {
            int xorukup = 0;
            int andproiz = svi1 ? 1 : int.MaxValue;

            for (int r = l; r < n; r++)
            {
                xorukup ^= a[r];
                if (!svi1)
                    andproiz &= b[r];

                long trenutnavred = (long)xorukup * andproiz;
                if (trenutnavred > maxvred)
                    maxvred = trenutnavred;
            }
        }

        Console.WriteLine(maxvred);
    }
}