using System;

public class HelloWorld
{
    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = new int[N];
        int[] B = new int[N];
        
        for(int i = 0;i<2; i++)
        {
           string[] s = Console.ReadLine().Split();
           for(int j = 0;j<N; j++)
           {
               if(i == 0)A[j] = int.Parse(s[j]);
               if(i == 1)B[j] = int.Parse(s[j]);
           }
        }
        int x = A[0];
        int y = B[0];
        int z = 1;
        int max = 0;
        for(int i = 1;i<N; i++)
        {
           int i1 = i;
           for(int j = i+1;j<N; j++)
           {
               
               while(i1<= j)
               {
                   x ^= A[i1];
                   y &= B[i1];
                   i1++;
               }
           }
           z = x*y;
           if(z>max) max = z;
           x = A[i];
           y = B[i];
           z = 1;
        }
        Console.WriteLine(max);
        
    }
}