#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 7;
long long val[N];
long long mask[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  long long sum = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> val[i] >> mask[i];
    sum += val[i];
  }
  if (sum < 0) {
    for (long long i = 1; i <= n; i++) val[i] = -val[i];
    sum = -sum;
  }
  long long ans = 0;
  for (long long i = 0; i <= 62; i++) {
    long long a = 0, b = 0, c = 0;
    for (long long j = 1; j <= n; j++) {
      if (mask[j] == 0) continue;
      if (mask[j] == (1LL << i))
        a += val[j];
      else if (mask[j] & (1LL << i))
        b += val[j];
      else
        c += val[j];
    }
    if (a > 0) {
      ans |= 1LL << i;
      for (long long j = 1; j <= n; j++)
        if (mask[j] & (1LL << i)) val[j] = -val[j];
    }
    for (long long j = 1; j <= n; j++) mask[j] &= ~(1LL << i);
  }
  cout << ans << endl;
}
