#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> val(n), mask(n);
  long long sum_init = 0;
  for (int i = 0; i < n; ++i) {
    cin >> val[i] >> mask[i];
    sum_init += val[i];
  }
  if (sum_init < 0) {
    for (int i = 0; i < n; ++i) val[i] = -val[i];
    sum_init = -sum_init;
  }
  long long ans = 0;
  for (int k = 1; k <= 62; k++) {
    long long s = 0;
    long long r = (1LL << k) - 1;
    long long l = (1LL << (k - 1));
    for (int i = 0; i < n; ++i) {
      if (mask[i] <= r && mask[i] >= l) s += val[i];
    }
    if (s > 0) {
      for (int i = 0; i < n; ++i) {
        if (mask[i] & (1LL << (k - 1))) val[i] = -val[i];
      }
      ans += 1LL << (k - 1);
    }
  }
  cout << ans;
}
