#include <bits/stdc++.h>
const int N = 3e5 + 5;
int n, v[N];
long long s[N];
int main() {
  scanf("%d", &n);
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%lld", &v[i], &s[i]);
    sum += v[i];
  }
  if (sum < 0) {
    for (int i = 1; i <= n; i++) v[i] *= -1;
  }
  long long ans = 0;
  for (int k = 0; k < 62; k++) {
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
      if ((1LL << k) <= s[i] && s[i] < (1LL << (k + 1))) {
        sum += ((__builtin_popcountll(ans & s[i]) & 1) ? v[i] : -v[i]);
      }
    }
    if (sum < 0) ans |= (1LL << k);
  }
  printf("%lld\n", ans);
  return 0;
}
