#include <bits/stdc++.h>
using namespace std;
int n, val[310000], a[310000];
long long ans, sum, mask[310000];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%lld", &val[i], &mask[i]);
    sum += val[i];
    for (a[i] = 61; a[i] >= 0; a[i]--)
      if (mask[i] & (1ll << a[i])) break;
  }
  if (sum < 0)
    for (int i = 1; i <= n; i++) val[i] = -val[i];
  for (int i = 0; i <= 61; i++) {
    long long s = 0;
    for (int j = 1; j <= n; j++)
      if (a[j] == i) s += val[j];
    if (s > 0) {
      ans |= (1ll << i);
      for (int j = 1; j <= n; j++)
        if (mask[j] & (1ll << i)) val[j] = -val[j];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
