#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int maxn = 3 * 100000 + 10;
struct node {
  long long val;
  long long mask;
  node(int val = 0, long long mask = 0) : val(val), mask(mask) {}
} ob[maxn];
int getbitpos(long long x) {
  int pos = -1;
  while (x > 0) {
    x >>= 1;
    pos++;
  }
  return pos;
}
long long lowbit(long long x) { return x & (-x); }
long long sum;
long long ans;
int main() {
  int n;
  n = (int)read();
  for (int i = 0; i < n; i++) {
    ob[i].val = read();
    ob[i].mask = read();
    sum += ob[i].val;
  }
  for (int i = 0; i <= 62; i++) {
    long long tsum = 0;
    for (int j = 0; j < n; j++) {
      if (getbitpos(ob[j].mask) == i) tsum += ob[j].val;
    }
    if ((tsum > 0 && sum > 0) || (tsum < 0 && sum < 0)) {
      ans += (1LL << i);
      for (int j = 0; j < n; j++) {
        if (ob[j].mask >> i & 1) ob[j].val *= -1;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
