#include <bits/stdc++.h>
using namespace std;
const long long N = 1000005;
long long n;
long long val[N], mask[N];
vector<long long> G[65];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> val[i] >> mask[i];
    for (long long j = 61; j >= 0; j--) {
      if ((mask[i] >> j) & 1) {
        G[j].push_back(i);
        break;
      }
    }
    sum += val[i];
  }
  if (sum < 0) {
    sum *= -1;
    for (long long i = 1; i <= n; i++) val[i] *= -1;
  }
  long long ans = 0;
  for (long long j = 0; j <= 61; j++) {
    long long s = 0;
    for (auto i : G[j]) s += val[i];
    if (s > 0) {
      ans |= (1ll << j);
      for (long long i = 1; i <= n; i++)
        if ((mask[i] >> j) & 1) val[i] *= -1;
    }
  }
  cout << ans;
  return 0;
}
