#include <bits/stdc++.h>
using namespace std;
long long sl, fh, ans, tot, msk[300010];
int n, val[300010];
long long rd() {
  sl = 0;
  fh = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') sl = sl * 10 + ch - '0', ch = getchar();
  return sl * fh;
}
int main() {
  n = rd();
  for (int i = 1; i <= n; ++i) val[i] = rd(), msk[i] = rd(), tot += val[i];
  if (tot < 0)
    for (int i = 1; i <= n; ++i) val[i] = -val[i];
  for (int bt = 0; bt < 62; ++bt) {
    tot = 0;
    for (int i = 1; i <= n; ++i)
      if (msk[i] && !(msk[i] >> 1)) tot += val[i];
    if (tot > 0) {
      ans |= 1ll << bt;
      for (int i = 1; i <= n; ++i)
        if (msk[i] & 1) val[i] = -val[i];
    }
    for (int i = 1; i <= n; ++i) msk[i] >>= 1;
  }
  printf("%lld\n", ans);
  return 0;
}
