#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int n;
long long sm, ans, a[N], mk[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = (1); i <= (n); i++) cin >> a[i] >> mk[i], sm += a[i];
  if (sm < 0)
    for (int i = (1); i <= (n); i++) a[i] = -a[i];
  for (int i = 62; ~i; i--) {
    sm = 0;
    for (int j = (1); j <= (n); j++)
      if (mk[j] == 1ll << i) sm += a[j];
    if (sm > 0) ans |= 1ll << i;
    for (int j = (1); j <= (n); j++)
      if (mk[j] & (1ll << i)) {
        mk[j] ^= 1ll << i;
        if (sm > 0) a[j] = -a[j];
      }
  }
  cout << ans << endl;
  return 0;
}
