#include <bits/stdc++.h>
using namespace std;
long long read(long long x = 0) {
  long long c, f = 1;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f * x;
}
long long a[300010], mask[300010], N, s;
vector<long long> lis[70];
int main() {
  long long N(read()), i, j, ans(0);
  for (i = 1; i <= N; i++) a[i] = read(), mask[i] = read(), s += a[i];
  if (s < 0)
    for (i = 1; i <= N; i++) a[i] = -a[i];
  for (i = 0; i < 62; i++) {
    long long s = 0;
    for (j = 1; j <= N; j++)
      if ((mask[j] >> i) == 1) s += a[j];
    if (s > 0) {
      ans |= 1ll << i;
      for (j = 1; j <= N; j++)
        if (mask[j] & (1ll << i)) a[j] = -a[j];
    }
  }
  cout << ans;
  return 0;
}
