#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  long long int val[n];
  long long int mask[n];
  long long int first[n];
  long long int total = 0;
  for (int i = 0; i < n; i++) {
    cin >> val[i] >> mask[i];
    total += val[i];
    first[i] = __builtin_ctzll(mask[i]);
  }
  if (total < 0) {
    for (int i = 0; i < n; i++) val[i] *= -1;
    total *= -1;
  }
  long long int answer = 0;
  for (int bit = 62; bit >= 0; bit--) {
    long long int profit = 0, loss = 0;
    for (int i = 0; i < n; i++) {
      if (first[i] != bit) continue;
      long long int onecount = __builtin_popcountll(answer & mask[i]);
      if (onecount % 2 == 0)
        profit += val[i];
      else
        loss += val[i];
    }
    if (loss < profit) {
      answer |= (1LL << bit);
    }
  }
  cout << answer;
  return 0;
}
