#include <bits/stdc++.h>
using namespace std;
long long vals[300001];
long long masks[300001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long val_sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> vals[i] >> masks[i];
    val_sum += vals[i];
  }
  bool positive = val_sum > 0;
  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 = masks[i];
    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) {
      long long& val = vals[j];
      long long& mask = masks[j];
      if (__builtin_popcountll(ans & mask) & 1) {
        sum -= val;
      } else {
        sum += val;
      }
    }
    if (val_sum > 0) {
      if (sum > 0) ans |= powers[i];
    } else {
      if (sum < 0) ans |= powers[i];
    }
  }
  cout << ans << endl;
  return 0;
}
