#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, w[N];
long long msk[N];
int main() {
  scanf("%d", &n);
  long long s = 0, ans = 0;
  for (int i = 1; i <= n; i++) scanf("%d%lld", &w[i], &msk[i]), s += w[i];
  if (s > 0)
    for (int i = 1; i <= n; i++) w[i] = -w[i];
  for (int j = 0; j < 62; j++) {
    s = 0;
    for (int i = 1; i <= n; i++)
      if ((msk[i] >> j) == 1) s += w[i];
    if (s < 0) {
      ans |= 1ll << j;
      for (int i = 1; i <= n; i++)
        if (msk[i] >> j & 1) w[i] = -w[i];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
