using System;
namespace Dvaniza
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string input = Console.ReadLine();
            string[] As = input.Split();
            int[] A = new int[n];
            for (int i = 0; i < n; i++)
            {
                A[i] = int.Parse(As[i]);
            }

            input = Console.ReadLine();
            string[] Bs = input.Split();
            int[] B = new int[n];
            for (int i = 0; i < n; i++)
            {
                B[i] = int.Parse(Bs[i]);
            }

            int max = 0;
            for (int i = 0; i < n; i++)
            {
                int trenA = 0;
                int trenB = int.MaxValue;

                for (int j = i; j < n; j++)
                {
                    trenA ^= A[j];
                    trenB &= B[j];

                    int rez = trenA * trenB;
                    max = Math.Max(max, rez);
                }
            }
            Console.WriteLine(max);
        }
    }
}