#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar();
  return X * w;
}
const long long N = 300000 + 10;
long long n, ans = 0, sum = 0;
long long val[N], mask[N];
signed main() {
  n = read();
  for (register long long i = 1; i <= n; ++i)
    val[i] = read(), mask[i] = read(), sum += val[i];
  if (sum < 0)
    for (register long long i = 1; i <= n; ++i) val[i] = -val[i];
  for (register long long i = 62; ~i; --i) {
    long long now = 0;
    for (register long long j = 1; j <= n; ++j)
      if (mask[j] == (1ll << i)) now += val[j];
    if (now > 0) ans |= (1ll << i);
    for (register long long j = 1; j <= n; ++j) {
      if (!(mask[j] & (1ll << i))) continue;
      mask[j] ^= (1ll << i);
      if (now > 0) val[j] = -val[j];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
