using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[n];
        int[] b = new int[n];
        string[] unosa = Console.ReadLine().Split();
        string[] unosb = Console.ReadLine().Split();
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(unosa[i]);
            b[i] = int.Parse(unosb[i]);
        }
        long odg = long.MinValue;
        for (int i = 0; i < n; i++)
        {
            int txor = a[i];
            int tand = b[i];
            for (int j = i+1; j < n; j++)
            {
                txor = txor ^ a[j];
                tand = tand & b[j];
                odg = Math.Max(odg, txor*tand);
            }
        }
        Console.WriteLine(odg);
    }
}