#include <iostream>
#include <vector>
#include <limits>
using namespace std;
	int n;
vector<uint32_t> A;
vector<uint32_t> B;

uint64_t Compute(int low, int up)
{
	uint32_t XOR_rez = 0;
	for (int i = low; i <= up; ++i)
	{
		XOR_rez ^= A[i];
	}
	uint32_t AND_rez = numeric_limits<uint32_t>::max();
	for (int i = low; i <= up; ++i)
	{
		AND_rez &= B[i];
	}
	return static_cast<uint64_t>(XOR_rez) * static_cast<uint64_t>(AND_rez);
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		uint32_t t;
		cin >> t;
		A.push_back(t);
	}
	for (int i = 0; i < n; ++i)
	{
		uint32_t t;
		cin >> t;
		B.push_back(t);
	}

	uint64_t maxv = 0;

	for (int i = 0; i < n; ++i)
	{
		for (int j = i; j < n; ++j)
		{
			maxv = max(maxv, Compute(i,j));
		}
	}
	cout << maxv << "\n";
}