#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline ll read() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const ll N = 3e5 + 10, M = 1e2 + 10;
vector<ll> p[M], q[M];
ll s[N], id[N], sum, now = 1, ans;
int main() {
  ll n = read();
  for (ll i = 1; i <= n; i++) {
    s[i] = read();
    id[i] = read();
    sum += s[i];
    bool fl = false;
    for (ll j = 61; j >= 0; j--)
      if (id[i] >> j & 1) {
        if (fl == false) {
          fl = true;
          q[j].push_back(i);
        }
        p[j].push_back(i);
      }
  }
  for (ll i = 0; i < 62; i++) {
    ll tot = 0;
    for (ll j = 0; j < q[i].size(); j++) tot += s[q[i][j]];
    if ((sum > 0 && tot > 0) || (sum < 0 && tot < 0)) {
      ans += now;
      for (ll j = 0; j < p[i].size(); j++) s[p[i][j]] *= -1;
    }
    now <<= 1;
  }
  printf("%lld\n", ans);
  return 0;
}
