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

    namespace DvaNiza
    {
        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[] brojeviA = Console.ReadLine().Split(' ');
                string[] brojeviB = Console.ReadLine().Split(' ');
                int max = 0;

                for (int i = 0; i < N; i++) 
                {
                    A[i] = int.Parse(brojeviA[i]);
                    B[i] = int.Parse(brojeviB[i]);
                }

                for (int L = 0; L < N; L++)
                {
                    int XOR = 0;
                    int AND = ~0; 

                    for (int R = L; R < N; R++)
                    {
                        XOR ^= A[R];  
                        AND &= B[R];  

                        
                        int Vrednost = XOR * AND;
                        max = Math.Max(max, Vrednost); 
                    }
                }

                Console.WriteLine(max);

            }
        }
    }