#include <bits/stdc++.h>
using namespace std;
int n;
vector<pair<int, long long>> v[63];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int val;
    long long mask;
    cin >> val >> mask;
    sum += val;
    int j = 62;
    while (!(mask & (1LL << j))) j--;
    v[j].push_back(make_pair(val, mask));
  }
  if (sum > 0)
    for (int j = 0; j < 63; j++)
      for (auto& p : v[j]) p.first *= -1;
  long long s = 0;
  for (int j = 0; j < 63; j++) {
    sum = 0;
    for (auto& p : v[j]) {
      p.second &= s;
      int b = 0;
      for (int k = 0; k < j; k++)
        if (p.second & (1LL << k)) b++;
      sum += (b % 2 ? -p.first : p.first);
    }
    if (sum < 0) s |= (1LL << j);
  }
  cout << s << endl;
  return 0;
}
