#include <bits/stdc++.h>
using namespace std;
using ii = pair<long long, long long>;
using vb = vector<bool>;
using vi = vector<long long>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vii obj(n);
  for (long long i = 0; i < n; i++) {
    cin >> obj[i].first >> obj[i].second;
  }
  {
    long long sum = 0;
    for (auto &[val, mask] : obj) {
      sum += val;
    }
    if (sum < 0)
      for (auto &[val, mask] : obj) {
        val = -val;
      }
  }
  vvii g(62);
  for (auto &[val, mask] : obj) {
    long long group = __builtin_ctzll(mask);
    g[group].push_back({val, mask});
  }
  long long s = 0;
  for (long long bit = 61; bit >= 0; bit--) {
    long long sum = 0;
    for (auto &[val, mask] : g[bit]) {
      if (__builtin_parityll(mask & s)) {
        sum += -val;
      } else {
        sum += val;
      }
    }
    if (sum > 0) s += (1LL << bit);
  }
  cout << s << '\n';
}
