#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template <class T>
ostream& prnt(ostream& out, T v) {
  out << v.size() << '\n';
  for (auto e : v) out << e << ' ';
  return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> v) {
  return prnt(out, v);
}
template <class T>
ostream& operator<<(ostream& out, set<T> v) {
  return prnt(out, v);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, map<T1, T2> v) {
  return prnt(out, v);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  return out << '(' << p.first << ' ' << p.second << ')';
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
long long n;
vector<pair<unsigned long long, long long> > v;
long long val, ans, sum;
unsigned long long mask;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> val >> mask;
    v.push_back({mask, val});
    sum += val;
  }
  sort(v.begin(), v.end());
  long long i = 0;
  for (unsigned long long step = 1; step <= (1LL << 62); step *= 2) {
    long long new_sum = 0;
    while (i < v.size() && (v[i].first < step)) {
      if (__builtin_popcountll(v[i].first & ans) % 2 == 0)
        new_sum += v[i].second;
      else
        new_sum -= v[i].second;
      i++;
    }
    if (new_sum == 0) continue;
    if (sum > 0 && new_sum > 0 || sum < 0 && new_sum < 0) ans += step / 2;
  }
  cout << ans << '\n';
}
