#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n;
long long a[maxn], b[maxn], sum, S;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%lld%lld", &a[i], &b[i]), sum += a[i];
  if (sum < 0)
    for (int i = (1); i <= (n); ++i) a[i] = -a[i];
  for (int i = (61); i >= (0); --i) {
    long long dl = 0;
    for (int j = (1); j <= (n); ++j)
      if (b[j] == (1ll << i)) dl += a[j];
    if (dl > 0) S |= 1ll << i;
    for (int j = (1); j <= (n); ++j)
      if (b[j] & (1ll << i)) {
        b[j] ^= 1ll << i;
        if (dl > 0) a[j] = -a[j];
      }
  }
  printf("%lld\n", S);
  return 0;
}
