#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using MASK = bitset<64>;
inline int count(LL mask) { return (bitset<64>(mask)).count(); }
const int LOG = 63;
vector<pair<LL, LL>> vals[LOG];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  LL total = 0;
  for (int i = 0; i < n; i++) {
    LL val, mask;
    cin >> val >> mask;
    int j;
    for (j = LOG - 1; j >= 0; j--) {
      if (mask >> j) break;
    }
    vals[j].emplace_back(val, mask);
    total += val;
  }
  if (total < 0) {
    for (int j = 0; j < LOG; j++) {
      for (auto& e : vals[j]) e.first *= -1;
    }
  }
  LL s = 0;
  for (int j = 0; j < LOG; j++) {
    LL sum = 0;
    for (auto& e : vals[j]) {
      sum += (count(e.second & s) % 2 ? -1 : 1) * e.first;
    }
    if (sum > 0) s |= 1ll << j;
  }
  cout << s << endl;
  return 0;
}
