#include <bits/stdc++.h>
using namespace std;
long long a[300005], m[300005], t[300005], ans, sum, n, x, qwq;
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld%lld", &a[i], &m[i]);
    x = m[i];
    while (x) {
      x >>= 1ll;
      t[i]++;
    }
    sum += a[i];
  }
  if (sum < 0)
    for (long long i = 1; i <= n; i++) a[i] *= -1ll;
  for (long long i = 0; i <= 62; i++) {
    qwq = 0ll;
    for (long long j = 1; j <= n; j++)
      if (m[j] & (1ll << i) && t[j] - 1ll == i) qwq += a[j];
    if (qwq > 0) {
      for (long long j = 1; j <= n; j++)
        if (m[j] & (1ll << i)) a[j] *= -1ll;
      ans += (1ll << i);
    }
  }
  printf("%lld", ans);
  return 0;
}
