#include <iostream>
#define ll long long
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  ll a[n], b[n];
  for (int i=0; i<n; i++) scanf("%lld", &a[i]);
  for (int i=0; i<n; i++) scanf("%lld", &b[i]);
  ll res = 0;
  ll xorv, andv, val;
  for (int l=0; l<n; l++) {
    xorv = 0;
    andv = (1ll << 32)-1;
    for (int r=l; r<n; r++) {
      xorv = xorv^a[r];
      andv = andv&b[r];
      val = xorv * andv;
      if (val > res) res = val;
    }
  }
  printf("%lld", res);
}