#include <bits/stdc++.h>
using namespace std;
int n;
long long v[400100];
unsigned long long m[400100];
vector<int> d[100];
unsigned long long bm(int i, int j) {
  return (((unsigned long long)1) << j) - (((unsigned long long)1) << i);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(12);
  cin >> n;
  long long ts = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i] >> m[i], ts += v[i];
    if (__builtin_popcountll(m[i]) & 1)
      d[0].push_back(i);
    else
      d[__builtin_ctzll(m[i]) + 1].push_back(i);
  }
  unsigned long long s = 0;
  for (int i = 61; i >= 0; i--) {
    long long sh = 0;
    for (int j : d[i + 1])
      sh += (__builtin_popcountll(m[j] & s) & 1 ? -v[j] : v[j]);
    if (sh > 0 && ts > 0 || sh < 0 && ts < 0) s |= ((unsigned long long)1) << i;
  }
  long long sh = 0;
  for (int j : d[0]) sh += (__builtin_popcountll(m[j] & s) & 1 ? -v[j] : v[j]);
  if (sh > 0 && ts > 0 || sh < 0 && ts < 0) s ^= bm(0, 62);
  cout << s << "\n";
}
