#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int B = 62;
ll solve(vector<pair<int, ll>>& a, int b = B - 1) {
  if (b < 0) {
    ll sum = 0;
    for (auto p : a) {
      sum += p.first;
    }
    assert(sum < 0);
    return 0;
  }
  ll bit = 1ll << b;
  ll sum1 = 0;
  for (auto p : a) {
    if ((p.second & bit) && (p.second & (bit - 1)) == 0) {
      sum1 += p.first;
    }
  }
  ll res = 0;
  if (sum1 > 0) {
    res ^= bit;
    for (auto& p : a) {
      if (p.second & bit) {
        p.first *= -1;
      }
    }
  }
  return res ^ solve(a, b - 1);
}
signed main() {
  mt19937 rnd;
  int n;
  cin >> n;
  vector<pair<int, ll>> val(n);
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> val[i].first >> val[i].second;
    sum += val[i].first;
  }
  if (sum < 0) {
    for (int i = 0; i < n; ++i) {
      val[i].first *= -1;
    }
  }
  ll res = solve(val);
  cout << res << '\n';
}
