#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
template <typename T>
inline void read(T &WOW) {
  T x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  WOW = flag * x;
}
int n;
long long val[MAXN], mask[MAXN];
void solve() {
  read(n);
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    read(val[i]);
    read(mask[i]);
    sum += val[i];
  }
  long long s = 0;
  for (int i = 0; i <= 61; ++i) {
    long long cur = 0;
    for (int j = 1; j <= n; ++j) {
      if (((mask[j] >> i) & 1) && mask[j] < (1LL << (i + 1))) {
        cur += val[j];
      }
    }
    if (cur == 0) continue;
    if ((cur > 0) == (sum > 0)) {
      s |= (1LL << i);
      for (int j = 1; j <= n; ++j) {
        if ((mask[j] >> i) & 1) {
          val[j] = -val[j];
        }
      }
    }
  }
  printf("%lld\n", s);
}
int main() {
  solve();
  return 0;
}
