#include <bits/stdc++.h>
using namespace std;
vector<int> p;
int db = 100;
long long sum;
int n;
vector<pair<long long, long long> > v;
bool ans(long long a) {
  long long er = 0;
  for (int i = 0; i < n; i++) {
    long long p = 0;
    long long x = a, y = v[i].second;
    while (x > 0 && y > 0) {
      if (x % 2 == 1 && y % 2 == 1) {
        p++;
      }
      x /= 2;
      y /= 2;
    }
    long long k = v[i].first;
    if (p % 2 == 1) {
      er -= k;
    } else {
      er += k;
    }
  }
  if (sum > 0 && er < 0) {
    return true;
  }
  if (sum < 0 && er > 0) {
    return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  for (int i = 1; i <= 6200; i++) {
    int x = 0;
    if (i % 5 != 0) {
      x = 1;
    }
    p.push_back(x);
  }
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long a, b;
    cin >> a >> b;
    sum += a;
    v.push_back({a, b});
  }
  long long r = (long long)1 << 62;
  r--;
  if (ans(r)) {
    cout << r << endl;
    return 0;
  }
  if (ans(65536 * 6)) {
    cout << 65536 * 6 << endl;
    return 0;
  }
  for (long long i = 0; i <= 61; i++) {
    for (long long j = i + 1; j <= 61; j++) {
      r = 1 << i;
      r += 1 << j;
      if (ans(r)) {
        cout << r << endl;
        return 0;
      }
    }
  }
  while (true) {
    if (db == 100) {
      random_shuffle(p.begin(), p.end());
      db = 0;
    }
    long long a = 0;
    long long b = 1;
    for (int i = db * 62; i < db * 62 + 62; i++) {
      if (p[i] == 1) {
        a += b;
      }
      b *= 2;
    }
    if (ans(a)) {
      cout << a << endl;
      return 0;
    }
    db++;
  }
  return 0;
}
