#include <bits/stdc++.h>
using namespace std;
int val[300005];
long long num[300005];
int main() {
  int n;
  scanf("%d", &n);
  long long s = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d%lld", &val[i], &num[i]);
    s += val[i];
  }
  long long ans = 0;
  for (int i = 61; i >= 0; i--) {
    long long s0 = 0, s1 = 0;
    for (int j = 1; j <= n; j++)
      if ((num[j] & (1LL << i)) && (num[j] >> i << i) == num[j]) {
        bool v = (val[j] > 0) ^ (s > 0);
        for (int k = 0; k < 62; k++)
          if ((num[j] & ans) & (1LL << k)) v ^= 1;
        if (v)
          s0 += abs(val[j]);
        else
          s1 += abs(val[j]);
      }
    if (s1 > s0) ans ^= (1LL << i);
  }
  printf("%lld\n", ans);
  return 0;
}
