#include <bits/stdc++.h>
using namespace std;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
const int N = 3e5;
int n;
long long ans, sum;
pair<long long, int> a[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d %lld", &a[i].second, &a[i].first), sum += a[i].second;
  sort(a, a + n);
  int l = 0;
  long long cur = 2;
  while (1) {
    long long temp = 0;
    while (l < n && cur > a[l].first) {
      temp += a[l].second;
      l++;
    }
    if (sum < 0 && temp < 0 || sum > 0 && temp > 0) {
      ans ^= cur >> 1;
      for (int i = 0; i < n; i++)
        if (a[i].first & (cur >> 1)) a[i].second *= -1;
    }
    if (cur == (1ll << 62)) break;
    cur <<= 1;
  }
  cout << ans << endl;
}
