#include <bits/stdc++.h>
using namespace std;
template <typename tp>
inline void read(tp &x) {
  x = 0;
  char c = getchar();
  int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar())
    ;
  if (f) x = -x;
}
const long long N = 3e5 + 233;
long long n, sum, S;
long long s[N], val[N], id[N], pval[N];
vector<long long> vec[233];
signed main(void) {
  read(n);
  for (register long long i = 1; i <= (n); i++)
    read(val[i]), read(s[i]), sum += (pval[i] = val[i]);
  if (sum < 0) {
    for (register long long i = 1; i <= (n); i++) val[i] *= -1, pval[i] *= -1;
    sum *= -1;
  }
  for (long long k = 61; k >= 0; k--) {
    long long sum = 0;
    for (register long long i = 1; i <= (n); i++)
      if (s[i] == (1ll << k)) sum += val[i];
    for (register long long i = 1; i <= (n); i++)
      if (s[i] >> k & 1) {
        if (sum > 0) val[i] = -val[i];
        s[i] ^= 1ll << k;
      }
    if (sum > 0) S |= 1ll << k;
  }
  cerr << S << "\n";
  long long cs = 0, sum = 0;
  for (register long long i = 1; i <= (n); i++)
    cs += __builtin_popcount(s[i] & S) & 1 ? -pval[i] : pval[i];
  for (register long long i = 1; i <= (n); i++) sum += pval[i];
  cerr << sum << " " << cs << "\n";
  cout << S << "\n";
}
