#include <iostream>

void niz_citaj(unsigned int* &a, int n){
  a = new unsigned int[n];
  for(int i = 0; i < n; i++)
    std::cin >> a[i];
}

int main(){
  unsigned int *a, *b, n;
  std::cin >> n;
  niz_citaj(a, n);
  niz_citaj(b, n);
  unsigned int max = 0;
  for(int i = 0; i < n; i++){
    unsigned int xr = 0;
    unsigned int ad = 0xFFFFFFFF;
    unsigned int p = 0;
    for(int j = i; j < n; j++){
      xr ^= a[j];
      ad &= b[j];
      p = xr * ad;
      if(p > max)
        max = p;
    }
  }
  std::cout << max << std::endl;
  return 0;
}