using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
    internal class Program
    {
        static int func(int n, int[] a, int[] b)
        {
            int br = 0;
            for (int i = 0; i < n; i++)
            {
                int niza = 0;
                int nizb = b[i];
                for (int j = i; j < n; j++)
                {
                    niza ^= a[j];
                    nizb &= b[j];
                    if (nizb == 0)
                        break;
                    int br1 = niza * nizb;
                    br = Math.Max(br, br1);
                }
            }
            return br;
        }
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            string[] s1 = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s1[i]);
            }
            string[] s2 = Console.ReadLine().Split(' ');
            int[] b = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s2[i]);
            }
            Console.WriteLine(func(n, a, b));
            Console.ReadLine();
        }
    }
}