#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, long long> a[400001], b[400001];
long long s = 0, sol = 0;
long long c[400001];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%lld", &a[i].first, &a[i].second);
    b[i] = a[i];
    s += a[i].first;
    c[i] = 1;
    while (c[i] * 2 <= a[i].second) c[i] *= 2;
  }
  if (s > 0) {
    for (int i = 1; i <= n; i++) a[i].first *= -1;
  }
  for (int i = 0; i <= 62; i++) {
    long long v = (1LL) << i;
    long long contri = 0;
    for (int j = 1; j <= n; j++) {
      if (c[j] == v) contri -= a[j].first;
    }
    if (contri > 0) {
      for (int j = 1; j <= n; j++)
        if (v & a[j].second) a[j].first *= -1;
      sol += v;
    }
  }
  cout << sol << endl;
}
