using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void bin(List<int> a, int b)
        {
            a.Add(b % 2);
            if (b > 1)
                bin(a, b / 2);
        }
        static int dec(List<int> a, int k,int d)
        {
            if (d>=a.Count)
                return 0;
            return a[d]*k + dec(a, k * 2, d + 1);
        }
        static void and(List<int> a, List<int> b, int k)
        {
            if (a.Count != b.Count) {
                while (a.Count < b.Count)
                    a.Add(0);
                while (b.Count < a.Count)
                    b.Add(0);
            }
            if (a[k] + b[k] == 2)
                a[k] = 1;
            else a[k] = 0;
            if (k < a.Count-1)
                and(a,b,k+1);
        }
        static void xor(List<int> a, List<int> b, int k)
        {
            if (a.Count != b.Count)
            {
                while (a.Count < b.Count)
                    a.Add(0);
                while (b.Count < a.Count)
                    b.Add(0);
            }
            if (a[k] + b[k] == 1)
                a[k] = 1;
            else a[k] = 0;
            if (k < a.Count - 1)
                xor(a, b, k + 1);
        }
        static void Main(string[] args)
        {
            string[] c;
            int n = int.Parse(Console.ReadLine()),b=0,max1,max2;
            int[,] a = new int[2, n];
            List<int> A = new List<int>();
            List<int> B = new List<int>();
            for (int i = 0; i < 2; i++)
            {
                c = Console.ReadLine().Split(' ');
                for (int j = 0; j < n; j++)
                    a[i, j] = int.Parse(c[j]);
            }
            max1 = -1; max2 = -2;
            for (int i = 0; i < n-1; i++)
            {
                A.Clear();
                bin(A, a[0, i]);
                for(int j = i + 1; j < n; j++)
                {
                    B.Clear();
                    bin(B, a[0, j]);
                    xor(A, B, 0);
                    max1 = Math.Max(max1, dec(A, 1, 0));
                }
                A.Clear();
                bin(A, a[1, i]);
                for (int j = i + 1; j < n; j++)
                {
                    B.Clear();
                    bin(B, a[1, j]);
                    and(A, B, 0);
                    max2 = Math.Max(max2, dec(A, 1, 0));
                }
            }
            Console.WriteLine(max1*max2);
            Console.ReadLine();
        }
    }
}