#include <bits/stdc++.h>
long long inp() {
  char c = getchar();
  int neg = 1;
  while (c < '0' || c > '9') {
    if (c == '-') neg = -1;
    c = getchar();
  }
  long long sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * neg;
}
long long v[300010], mask[300010];
int main() {
  int n = inp();
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    v[i] = inp();
    sum += v[i];
    mask[i] = inp();
  }
  if (sum < 0)
    for (int i = 1; i <= n; i++) v[i] *= -1;
  long long s = 0;
  for (int i = 0; i <= 61; i++) {
    long long sum = 0;
    for (int j = 1; j <= n; j++) {
      if (mask[j] & (1ll << i)) {
        if (mask[j] <= (1ll << (i + 1))) {
          if (__builtin_popcountll(s & mask[j]) & 1)
            sum += v[j];
          else
            sum -= v[j];
        }
      }
    }
    if (sum < 0) s |= (1ll << i);
  }
  std::cout << s << std::endl;
}
