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