#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> val(n);
  vector<long long> mask(n);
  for (int i = 0; i < n; ++i) cin >> val[i] >> mask[i];
  long long sum = accumulate(val.begin(), val.end(), 0LL);
  long long s = 0;
  for (int k = 0; k < 62; ++k) {
    long long x = 0;
    for (int i = 0; i < n; ++i)
      if ((mask[i] >> k) == 1) x += val[i];
    cerr << x << endl;
    if (1.0 * sum * x > 0) {
      s |= 1LL << k;
      for (int i = 0; i < n; ++i)
        if (mask[i] >> k & 1) val[i] = -val[i];
    }
  }
  cout << s << endl;
  cerr << accumulate(val.begin(), val.end(), 0LL) << endl;
  return 0;
}
