#include <bits/stdc++.h>
using namespace std;
int N;
signed long long A[303030], B[303030];
vector<int> C[70];
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N;
  signed long long S = 0;
  for (i = 0; i < (N); i++) {
    cin >> A[i] >> B[i];
    S += A[i];
    x = 0;
    for (j = 0; j < (63); j++)
      if (B[i] & (1LL << j)) x = j;
    C[x].push_back(i);
  }
  if (S < 0) {
    for (i = 0; i < (N); i++) A[i] = -A[i];
  }
  signed long long mask = 0;
  for (i = 0; i < (63); i++) {
    signed long long T = 0;
    for (auto& c : C[i]) {
      if (__builtin_popcountll(B[c] & mask) % 2 == 1) {
        T -= A[c];
      } else {
        T += A[c];
      }
    }
    if (T > 0) mask |= 1LL << i;
  }
  cout << mask << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
