#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 100, M = 64;
long long n, sum, ans, val[N], mask[N];
vector<int> vec[M];
int hi_bit(long long mask) {
  for (int i = M - 1;; i--)
    if (mask & (1LL << i)) return i;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> val[i] >> mask[i];
    sum += val[i];
    vec[hi_bit(mask[i])].push_back(i);
  }
  if (sum > 0)
    for (int i = 0; i < n; i++) val[i] *= -1;
  for (int bit = 0; bit < M; bit++) {
    long long sum = 0;
    for (int dex : vec[bit]) sum += val[dex];
    if (sum >= 0) continue;
    ans |= 1LL << bit;
    for (int dex = 0; dex < n; dex++)
      if (mask[dex] & (1LL << bit)) val[dex] *= -1;
  }
  cout << ans;
  return 0;
}
