#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, long long> > a;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  a.resize(n);
  for (auto &i : a) cin >> i.first >> i.second;
  long long sum = 0;
  for (auto &i : a) sum += i.first;
  if (sum < 0) {
    sum *= -1;
    for (auto &i : a) i.first *= -1;
  }
  long long ans = 0;
  vector<int> cnt(n);
  for (int bit = 0; bit <= 61; bit++) {
    long long cur = 0;
    for (int i = 0; i < n; i++) {
      if (((1LL << bit) & a[i].second) == 0) continue;
      cnt[i]++;
      if (__builtin_popcountll(a[i].second) != cnt[i]) continue;
      cur += a[i].first;
    }
    if (cur > 0) {
      ans |= 1LL << bit;
      for (auto &i : a) {
        if ((1LL << bit) & i.second) {
          i.first *= -1;
        }
      }
    }
  }
  cout << ans << endl;
}
