#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int N = 3e5 + 20;
int n, val[N], mask[N], sum, ans;
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  cin >> n;
  for (int i = 0; i < n; i++) cin >> val[i] >> mask[i], sum += val[i];
  if (sum < 0) {
    for (int i = 0; i < n; i++) val[i] *= -1;
  }
  for (int b = 0; b < 62; b++) {
    int sum = 0;
    for (int i = 0; i < n; i++)
      if (mask[i] == (1ll << b)) sum += val[i];
    if (sum > 0) {
      ans |= (1ll << b);
      for (int i = 0; i < n; i++)
        if (mask[i] >> b & 1) val[i] *= -1;
    }
    for (int i = 0; i < n; i++)
      if (mask[i] >> b & 1) mask[i] ^= (1ll << b);
  }
  cout << ans << '\n';
}
