#include <bits/stdc++.h>
int mysign(long long x) {
  if (x == 0) return 0;
  if (x < 0) return -1;
  return 1;
}
long long val[300005];
long long mask[300005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &val[i], &mask[i]);
  long long fsum = 0;
  for (int i = 1; i <= n; i++) fsum += val[i];
  int tgt = mysign(fsum);
  long long ans = 0;
  for (int i = 0; i < 62; i++) {
    long long vsum = 0;
    for (int j = 1; j <= n; j++) {
      if (mask[j] >= (1ll << i) && mask[j] < (1ll << (i + 1))) vsum += val[j];
    }
    if (mysign(vsum) == tgt) {
      ans |= (1ll << i);
      for (int j = 1; j <= n; j++) {
        if ((mask[j] & (1ll << i)) == (1ll << i)) val[j] *= -1ll;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
