using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlTypes;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;

namespace zadatak
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = new int[n];
            int[] B = new int[n];
            string[] inputA = Console.ReadLine().Split();
            string[] inputB = Console.ReadLine().Split();
            int[] Axor = new int[n];
            for (int i = 0; i < n; i++) 
            {
                A[i] = int.Parse(inputA[i]);
                B[i] = int.Parse(inputB[i]);
            }
            if (n == 1)
                Console.WriteLine(A[0] * B[0]);
            else
            {
                Axor[0] = A[0];
                for (int i = 1; i < n; i++)
                    Axor[i] = Axor[i - 1] ^ A[i];
                int max = 0;
                for (int l = 0; l < n; l++)
                {
                    for (int r = l; r < n; r++)
                    {
                        int aSum;
                        if (l > 0)
                            aSum = Axor[r] ^ Axor[l - 1];
                        else
                            aSum = Axor[r];

                        int bSum = B[l];
                        for(int k = l + 1; k <= r;k++)
                            bSum = bSum & B[k];
                        if (aSum * bSum > max)
                        {
                            max = aSum * bSum;
                        }
                    }
                }
                Console.WriteLine(max);

            }
            Console.ReadLine();
        }
    }
}