#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
struct node {
  long long v, m;
  bool operator<(const node& a) const { return m < a.m; }
} a[N];
int main() {
  int n;
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 1; i <= n; i++)
    scanf("%lld%lld", &a[i].v, &a[i].m), sum += a[i].v;
  long long ans = 0;
  int p = 1;
  sort(a + 1, a + 1 + n);
  for (long long i = 0; i <= 61; i++) {
    if (p > n) break;
    long long s = 0;
    for (; a[p].m < (1ll << i + 1) && p <= n; p++) s += a[p].v;
    if ((sum > 0 && s > 0) || (sum < 0 && s < 0)) {
      ans |= 1ll << i;
      for (int j = p; j <= n; j++)
        if (a[j].m & (1ll << i)) a[j].v *= -1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
