#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(T&& x) {
  cout << x << "\n";
}
template <typename T, typename... S>
void print(T&& x, S&&... y) {
  cout << x << ' ';
  print(y...);
}
const long long Mod = 1000000007, Mod2 = 998244353;
const long long MOD = Mod2;
const long long maxn = 300005;
long long n, val[maxn], a[maxn], sum, ans;
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (long long i = (0); i < ((long long)(n)); i++) cin >> val[i] >> a[i];
  for (long long i = (0); i < ((long long)(n)); i++) sum += val[i];
  if (sum > 0)
    for (long long i = (0); i < ((long long)(n)); i++) val[i] *= -1;
  for (long long j = (61); j >= ((long long)(0)); j--) {
    sum = 0;
    for (long long i = (0); i < ((long long)(n)); i++)
      if (__builtin_ctzll(a[i]) == j) sum += val[i];
    if (sum < 0) {
      ans ^= (1ll << (j));
      for (long long i = (0); i < ((long long)(n)); i++)
        if (a[i] & (1ll << (j))) val[i] *= -1;
    }
  }
  sum = 0;
  for (long long i = (0); i < ((long long)(n)); i++)
    if (__builtin_popcountll(ans & a[i]) & 1) sum += val[i];
  print(ans);
  826;
  return 0;
}
