#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
long long n, m, i, j, a[300005], b[300005], ans, sum;
int main() {
  read(n);
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    read(a[i]);
    read(b[i]);
    sum += a[i];
  }
  if (sum < 0) {
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) a[i] *= -1;
    sum *= -1;
  }
  for ((i) = (0); (i) <= (62); (i)++) {
    long long s = 0;
    for (((j)) = (1); ((j)) <= ((n)); ((j))++)
      if ((1ll << i) <= b[j] && b[j] < (1ll << (i + 1))) {
        s += a[j];
      }
    if (s > 0) {
      ans |= (1ll << i);
      for (((j)) = (1); ((j)) <= ((n)); ((j))++)
        if (1 & (b[j] >> i)) a[j] *= -1;
    }
  }
  cout << ans << endl;
  return 0;
}
