/*
 * Created by SharpDevelop.
 * User: Paki
 * Date: 11/17/2024
 * Time: 11:28 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;

namespace TakmicenjeNizovi
{
	class Program
	{
		public static void Main(string[] args)
		{
			int N=int.Parse(Console.ReadLine());
			int[] A=new int[N];
			int[] B=new int[N];
			int max=0;
			int trenutnaA=0;
			int trenutnaB=0;
			
			string[] BrojeviA=Console.ReadLine().Split(' ');
			for(int i=0;i<N;i++)
			{
				
				A[i]=int.Parse(BrojeviA[i]);
			}
			
			string[] BrojeviB=Console.ReadLine().Split(' ');
			for(int i=0;i<N;i++)
			{
				
				B[i]=int.Parse(BrojeviB[i]);
			}			
			
			for(int i=0;i<N;i++)
			{
				for(int j=0;j<N;j++)
				{
					int L=i;
					int R=j;

					for(int J=L;J<R;J++)
					{
						
						trenutnaA=A[J]^A[J+1];
						trenutnaB=B[J]&B[J+1];
					}
					
					if(max<trenutnaA*trenutnaB)
					{
						max=trenutnaA*trenutnaB;
					}
				}

			}
			
			Console.WriteLine(max);
			
			// TODO: Implement Functionality Here
			
			Console.Write("Press any key to continue . . . ");
			Console.ReadKey(true);
		}
	}
}