#include <bits/stdc++.h>
using namespace std;
int N;
long long mask[300005];
long long val[300005];
long long sum, ans;
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lld %lld", &val[i], &mask[i]);
    sum += val[i];
  }
  if (sum < 0) {
    for (int i = 0; i < N; i++) val[i] *= -1;
  }
  for (long long i = 0; i < 62; i++) {
    long long partsum = 0;
    long long now = 1LL << i;
    long long next = 1LL << (i + 1);
    for (int j = 0; j < N; j++) {
      if (mask[j] >= now && mask[j] < next) {
        partsum +=
            ((__builtin_popcountll(mask[j] & ans) & 1) ? val[j] : -val[j]);
      }
    }
    if (partsum < 0) ans |= now;
  }
  printf("%lld", ans);
}
