#include <bits/stdc++.h>
using namespace std;
struct Ans {
  long long l;
  long long r;
  long long d;
};
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    v.push_back({x, y});
  }
  long long ans = 0;
  vector<bool> nec(n);
  fill(nec.begin(), nec.end(), false);
  long long sum = 0;
  for (long long i = 0; i < n; i++) sum += v[i].first;
  if (sum < 0) {
    for (long long i = 0; i < n; i++) v[i].first *= -1;
  }
  vector<long long> lb(n);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 62; j++) {
      long long ba = (1LL << j) & v[i].second;
      if (ba != 0) {
        lb[i] = j;
        break;
      }
    }
  }
  for (long long i = 61; i >= 0; i--) {
    long long tet = 0;
    for (long long j = 0; j < n; j++) {
      if (lb[j] != i) continue;
      if (!nec[j])
        tet += v[j].first;
      else
        tet += -v[j].first;
    }
    if (tet > 0) {
      ans += (1LL << i);
      for (long long j = 0; j < n; j++) {
        long long ba = (1LL << i) & v[j].second;
        if (ba != 0) {
          if (nec[j])
            nec[j] = false;
          else
            nec[j] = true;
        }
      }
    }
  }
  cout << ans;
}
