#include <bits/stdc++.h>
using namespace std;
inline long long v_in() {
  long long f = 1, sum = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    sum = (sum << 3) + (sum << 1) + (ch ^ 48);
    ch = getchar();
  }
  return sum * f;
}
const int M = 5e5 + 5;
int n;
long long sum, s, a[M], b[M];
int main() {
  n = v_in();
  for (register int i = 1; i <= n; i = -~i)
    a[i] = v_in(), b[i] = v_in(), sum += a[i];
  if (sum < 0)
    for (register int i = 1; i <= n; i = -~i) a[i] = -a[i];
  for (register int i = 61; i >= 0; i = ~-i) {
    sum = 0;
    for (register int j = 1; j <= n; j = -~j)
      if (b[j] == (1ll << i)) sum += a[j];
    if (sum > 0) s |= (1ll << i);
    for (register int j = 1; j <= n; j = -~j)
      if ((b[j] >> i) & 1) {
        b[j] ^= (1ll << i);
        if (sum > 0) a[j] = -a[j];
      }
  }
  printf("%lld\n", s);
  return 0;
}
