#include <bits/stdc++.h>
using namespace std;
const int apsz = 26;
const long long o = 1;
const int maxn = 300007;
const int ooi = 1e9 + 7;
const int up = 62;
int n;
long long mask[maxn];
long long val[maxn];
inline int hb(long long x) {
  int k = 0;
  while ((o << (k + 1)) <= x) k++;
  return k;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  long long sum = 0;
  for (int i = (0); i < (n); ++i) cin >> val[i] >> mask[i], sum += val[i];
  vector<vector<int> > pos(up);
  vector<vector<int> > exist(up);
  for (int i = (0); i < (n); ++i) {
    pos[hb(mask[i])].push_back(i);
    for (int j = (0); j < (up); ++j)
      if ((o << j) & mask[i]) exist[j].push_back(i);
  }
  long long ans = 0;
  for (int i = (0); i < (up); ++i) {
    if (pos[i].empty()) continue;
    long long tmp = 0;
    for (auto x : pos[i]) tmp += val[x];
    if (tmp == 0) continue;
    if (tmp > 0 == sum > 0) {
      ans |= (o << (long long)i);
      for (auto x : exist[i]) val[x] = -val[x];
    }
  }
  cout << ans << endl;
  return 0;
}
