using System;
using System.Collections.Generic;

namespace Petlja
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine() ?? "0");

            int[] A = new int[n];
            int[] B = new int[n];

            string[] a = Console.ReadLine()!.Split(' ');
            string[] b = Console.ReadLine()!.Split(' ');

            for (int i = 0; i < n; i++)
            {
                A[i] = int.Parse(a[i].ToString());
                B[i] = int.Parse(b[i].ToString());
            }

            int M = 0;
            for (int L = 0; L < n - 1; L++)
            {
                for (int R = L + 1; R < n; R++)
                {
                    int xor = 0;
                    int and = int.MaxValue;

                    for (int i = L; i <= R; i++)
                    {
                        xor ^= A[i];
                        and &= B[i];
                    }
                    int product = xor * and;
                    M = Math.Max(M, product);
                }
            }

            Console.WriteLine(M);
        }
    }
}