#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  vector<pair<long long, long long> > v(n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    sum += v[i].first;
    ;
  }
  if (sum > 0)
    for (pair<long long, long long> &p : v) p.first = -p.first;
  vector<pair<long long, long long> > u[62];
  for (pair<long long, long long> p : v) {
    int highbit = 63 - __builtin_clzll(p.second);
    u[highbit].push_back(p);
  }
  long long msk = 0;
  for (long long bit = 0; bit < 62; bit++) {
    long long sum = 0;
    for (pair<long long, long long> p : u[bit]) {
      if (__builtin_popcountll(msk & p.second) % 2 == 0)
        sum += p.first;
      else
        sum -= p.first;
    }
    if (sum < 0) msk |= 1ll << bit;
  }
  cout << msk << "\n";
  return 0;
}
