#include <bits/stdc++.h>
using namespace std;
const int maxn = 312345;
bool vis[maxn];
int n, val[maxn];
long long mask[maxn], ans;
int main() {
  scanf("%d", &n);
  long long tot = 0;
  for (int(i) = (1); (i) <= (n); (i)++) {
    scanf("%d%lld", val + i, mask + i);
    tot += val[i];
  }
  if (tot < 0)
    for (int(i) = (1); (i) <= (n); (i)++) val[i] = -val[i];
  for (int(bit) = (61); (bit) >= (0); (bit)--) {
    long long even = 0, odd = 0;
    for (int(i) = (1); (i) <= (n); (i)++)
      if (mask[i] == 1LL << bit) {
        if (!vis[i])
          even += val[i];
        else
          odd += val[i];
      }
    if (even > odd) {
      ans |= (1LL << bit);
      for (int(i) = (1); (i) <= (n); (i)++)
        if (mask[i] & (1LL << bit)) vis[i] ^= true;
    }
    for (int(i) = (1); (i) <= (n); (i)++) mask[i] &= ~(1LL << bit);
  }
  printf("%lld", ans);
}
