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

namespace ConsoleApp4
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] B = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            Console.WriteLine(maxVrednost(N, A, B));
        }

        static long maxVrednost(int N, int[] A, int[] B)
        {
            int[] prefiksXor = new int[N + 1];
            for (int i = 1; i <= N; i++)
            {
                prefiksXor[i] = prefiksXor[i - 1] ^ A[i - 1];
            }

            long max = 0;
            int L = 0;

            while (L < N)
            {
                int trAnd = B[L];
                int R = L;

                while (R < N && trAnd > 0)
                {
                    int trXor = prefiksXor[R + 1] ^ prefiksXor[L];
                    trAnd &= B[R];
                    max = Math.Max(max, (long)trXor * trAnd);
                    R++;
                }
                L++;
            }

            return max;
        }
    }
}