#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 7;
int n;
long long ans, now;
pair<long long, long long> a[N];
int max_bit[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    long long val, mask;
    scanf("%lld%lld", &val, &mask);
    now += val;
    a[i] = make_pair(val, mask);
    for (int j = 0; j < 62; j++) {
      if (mask >> j & 1) max_bit[i] = j;
    }
  }
  long long ans = 0;
  for (int i = 0; i < 62; i++) {
    long long sum = 0;
    for (int j = 1; j <= n; j++) {
      if (max_bit[j] == i) {
        sum += a[j].first;
      }
    }
    if (now > 0 && sum > 0 || now < 0 && sum < 0) {
      ans |= 1LL << i;
      for (int j = 1; j <= n; j++) {
        if (a[j].second >> i & 1) a[j].first = -a[j].first;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
