#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long val_sum = 0;
  vector<pair<long long, long long>> entries;
  long long val, mask;
  for (int i = 0; i < n; i++) {
    cin >> val >> mask;
    entries.push_back(make_pair(val, mask));
    val_sum += val;
  }
  vector<long long> hibit_to_entry[62];
  long long powers[62];
  for (int i = 0; i < 62; i++) {
    powers[i] = (1LL << i);
  }
  for (int i = 0; i < n; i++) {
    long long& mask = entries[i].second;
    for (int j = 61; j >= 0; j--) {
      if (mask & powers[j]) {
        hibit_to_entry[j].push_back(i);
        break;
      }
    }
  }
  long long ans = 0;
  int i = -1;
  for (auto& list : hibit_to_entry) {
    i++;
    int size = list.size();
    long long sum = 0;
    for (auto& j : list) {
      pair<long long, long long>& entry = entries[j];
      if (__builtin_popcountll(ans & entry.second) & 1) {
        sum -= entry.first;
      } else {
        sum += entry.first;
      }
    }
    if (val_sum > 0) {
      if (sum > 0) ans |= powers[i];
    } else {
      if (sum < 0) ans |= powers[i];
    }
  }
  cout << ans << endl;
  return 0;
}
