#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;
const ld EPS = 1e-9;
inline int cmp(ld first, ld second = 0, ld tol = EPS) {
  return (first <= second + tol) ? (first + tol < second) ? -1 : 0 : 1;
}
const int MOD = 1;
inline int mod(ll first, int m = MOD) { return (int)(((first % m) + m) % m); }
const int N = 3e5 + 10;
int n;
pair<ll, ll> a[N];
int main() {
  scanf("%d", &n);
  ll total = 0;
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", &a[i].second, &a[i].first);
    total += a[i].second;
  }
  if (total < 0)
    for (int i = 0; i < n; i++) a[i].second *= -1;
  sort(a, a + n);
  ll now = 1 << 1;
  total = 0;
  ll s = 0;
  int p = 0;
  for (int i = 0; i < n; i++) {
    while (a[i].first >= now) {
      if (total > 0) {
        s |= (1LL << p);
        for (int j = 0; j < n; j++)
          if ((1LL << p) & a[j].first) a[j].second *= -1;
      }
      total = 0;
      now <<= 1;
      ++p;
    }
    total += a[i].second;
  }
  if (total > 0) {
    s |= 1LL << p;
  }
  printf("%lld\n", s);
  return 0;
}
