#include <bits/stdc++.h>
const int N = 300005, W = 62;
int n, v[N], h[N];
long long a[N];
long long sum, ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%lld", &v[i], &a[i]);
    for (int j = W - 1; j >= 0; j--)
      if ((a[i] >> j) & 1) {
        h[i] = j;
        break;
      }
    sum += v[i];
  }
  if (sum < 0) {
    for (int i = 1; i <= n; i++) v[i] = -v[i];
    sum = -sum;
  }
  for (int i = 0; i < W; i++) {
    long long tot = 0;
    for (int j = 1; j <= n; j++)
      if (h[j] == i) tot += v[j];
    if (tot <= 0) continue;
    ans |= (1ll << i);
    for (int j = 1; j <= n; j++)
      if ((a[j] >> i) & 1) v[j] = -v[j];
  }
  printf("%lld\n", ans);
}
