#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long INF = mod * mod;
const long double eps = 1e-8;
void solve() {
  int n;
  cin >> n;
  vector<long long> val(n), mask(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> val[i] >> mask[i];
    sum += val[i];
  }
  if (sum < 0) {
    for (int i = 0; i < n; i++) {
      val[i] = -val[i];
      sum = -sum;
    }
  }
  long long ans = 0;
  for (int i = 0; i < 62; i++) {
    long long k = (long long)1 << i;
    long long csum = 0;
    for (int j = 0; j < n; j++) {
      if (mask[j] < 2 * k && (mask[j] & k)) {
        csum += val[j];
      }
    }
    if (csum > 0) {
      ans += k;
      for (int j = 0; j < n; j++) {
        if (mask[j] & k) {
          val[j] = -val[j];
        }
      }
    }
  }
  cout << ans << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}
