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

namespace peti
{
    internal class Program
    {
        static void Main(string[] args)
        { 
            int n = int.Parse(Console.ReadLine());
            string[] info = Console.ReadLine().Split();
            int[] niza = new int[n];
            int[] nizb = new int[n];
            for (int i = 0; i < n; i++) niza[i] = int.Parse(info[i]);
            info = Console.ReadLine().Split();
            for (int i = 0; i < n; i++) nizb[i] = int.Parse(info[i]);
            int max = int.MinValue;
            for (int l = 0; l < n; l++)
            {
                int a = 0;
                int b = nizb[l];
                for (int d = l; d < n; d++)
                {
                    a ^= niza[d];
                    b &= nizb[d];
                    if (a * b > max) max = a * b;
                }
            }
            Console.WriteLine(max);
        }
    }
}