using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp7
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] b = new int[n];
            b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int max = int.MinValue;
            for (int i = 0; i < n; i++)
            {
                int na = 0;
                int nb = -1;
                for (int j = i; j < n; j++)
                {
                    na ^= a[j];
                    if (nb == -1)
                        nb = b[j];
                    else
                        nb &= b[j];
                    int pr = na * nb;
                    if (pr > max)
                        max = pr;
                }
            }
            Console.WriteLine(max);
        }
    }
}