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

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