#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int n = 0;
	cin >> n;
	vector<long long> a1(n);
	vector<long long> b1(n);

	for (long long a = 0; a < n; a++)
		cin >> a1[a];
	for (long long a = 0; a < n; a++)
		cin >> b1[a];

	long long max1 = 0, valuet = 0;
	for (long long i = 0; i < n; i++)
	{
		long long temp1 = 0, temp2 = b1[i];
		for (long long j = i; j < n; j++)
		{
			temp1 = temp1 ^ a1[j];
			temp2 = temp2 & b1[j];
			valuet = temp1 * temp2;
			max1 = max(max1, valuet);
		}	
	}
	cout << max1 << endl;

	return 0;
}