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

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