#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  register T sum = 0;
  register char cc = getchar();
  int sym = 1;
  while (cc != '-' && (cc > '9' || cc < '0')) cc = getchar();
  if (cc == '-') sym = -1, cc = getchar();
  sum = sum * 10 + cc - '0';
  cc = getchar();
  while (cc >= '0' && cc <= '9') sum = sum * 10 + cc - '0', cc = getchar();
  return sym * sum;
}
template <typename T>
inline T read(T& a) {
  a = read<T>();
  return a;
}
template <typename T, typename... Others>
inline void read(T& a, Others&... b) {
  a = read(a);
  read(b...);
}
int n, val[300010];
long long ans, sum, mask[300010];
vector<int> bel[70];
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(val[i], mask[i]);
    for (int j = 62; j >= 0; j--)
      if (mask[i] & (1ll << j)) {
        bel[j].push_back(i);
        break;
      }
    sum += val[i];
  }
  if (sum < 0)
    for (int i = 1; i <= n; i++) val[i] = -val[i];
  for (int i = 0; i <= 62; i++) {
    long long t = 0;
    for (auto j : bel[i]) t += val[j];
    if (t > 0) {
      ans |= 1ll << i;
      for (int j = 1; j <= n; j++)
        if (mask[j] & (1ll << i)) val[j] = -val[j];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
