#include <bits/stdc++.h>
using namespace std;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N = 3e5 + 10;
const long long MOD = 1e9 + 9;
const long long M1 = 1e18 + 3, M2 = 1e9 + 7;
const long long p1 = 197, p2 = 229;
const int rx[4] = {-1, 0, 1, 0};
const int ry[4] = {0, 1, 0, -1};
const int hx[8] = {-2, -2, -1, 1, 2, 2, 1, -1};
const int hy[8] = {-1, 1, 2, 2, 1, -1, -2, -2};
const long double eps = 1e-7;
const long double pi = acos(-1.0);
const long long INF = 1e9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long val[n], mask[n], mb[n], startsum = 0;
  for (int i = 0; i < n; i++) {
    cin >> val[i] >> mask[i];
    startsum += val[i];
    mb[i] = 63 - __builtin_clzll(mask[i]);
  }
  long long mask_ans = 0;
  for (int i = 0; i < 62; i++) {
    long long cursum = 0;
    bool f = false;
    for (int j = 0; j < n; j++) {
      if (mb[j] == i) {
        f = true;
        if (__builtin_popcountll(mask[j] & mask_ans) % 2 == 1)
          cursum -= val[j];
        else
          cursum += val[j];
      }
    }
    if (f && cursum >= 0 && startsum > 0)
      mask_ans += (1ll << i);
    else if (f && cursum <= 0 && startsum < 0)
      mask_ans += (1ll << i);
  }
  cout << mask_ans << endl;
  return 0;
}
