using System;

namespace Programme
{
    class Programme
    {
        public static void printCharMatrix(char[,] arr, int n, int m)
        {
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    Console.Write(arr[i,j]);
                }
                Console.WriteLine();
            }
        }
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[] a = new int[n];
            int[] b = new int[n];
            string[] s = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(s[i]);
            }
            s = Console.ReadLine().Split(' ');
            for (int i = 0; i < n; i++)
            {
                b[i] = Convert.ToInt32(s[i]);
            }
            int currentValue = 0;
            int maxValue = 0;
            int tempA = 0;
            int tempB = 2147483647;
            for (int i = 0; i < n; i++)
            {
                for (int j = i; j < n; j++)
                {
                    tempA ^= a[j];
                    tempB &= b[j];
                    currentValue = tempA * tempB;
                    if (currentValue > maxValue)
                    {
                        maxValue = currentValue;
                    }
                }
                tempA = 0;
                tempB = 2147483647;
            }
            Console.WriteLine(maxValue);
        }
    }
}