using System;

namespace ConsoleApp10
{
    internal class Program
    {
        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(); string[] s1 = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(s[i]); b[i] = Convert.ToInt32(s1[i]);
            }
             Int64 max = Int64.MinValue;
         
            for (int L = 0; L < n; L++)
            {
                int xor = 0; 
                int and = -1; 
               
                for (int R = L; R < n; R++)
                {
                    xor = xor^a[R];
                    and = and & b[R]; 
                    Int64 z =xor * and;
                    if(max < z)
                    {
                        max = z;
                    }
                }
            }

            Console.WriteLine(max); Console.ReadKey();
        }
    }
}