#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int MAXN = 300010;
int N;
ll V[MAXN];
ull M[MAXN];
vector<ll> cnds[70];
int main() {
  cin >> N;
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> V[i] >> M[i];
    sum += V[i];
    cnds[63 - __builtin_clzll(M[i])].push_back(i);
  }
  if (sum > 0) {
    for (int i = 0; i < N; i++) {
      V[i] = -V[i];
    }
  }
  ull s = 0;
  for (int b = 0; b < 62; b++) {
    ll ev = 0;
    for (int i : cnds[b]) {
      if (__builtin_parityll(M[i] & (s | 1ull << b))) {
        ev -= V[i];
      } else {
        ev += V[i];
      }
    }
    if (ev > 0) {
      s |= 1ull << b;
    }
  }
  cout << s << endl;
  return 0;
}
