#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
struct objects {
  long long val, mask;
  int id;
};
objects r[maxn];
long long n, s, sum;
int main() {
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &r[i].val, &r[i].mask);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 62; j++)
      if ((r[i].mask >> j) & 1) r[i].id = j;
    sum += r[i].val;
  }
  if (sum < 0)
    for (int i = 1; i <= n; i++) r[i].val *= -1;
  for (int i = 0; i < 62; i++) {
    long long tmp = 0;
    for (int j = 1; j <= n; j++)
      if (r[j].id == i) tmp += r[j].val;
    if (tmp > 0) {
      s |= (1ll << i);
      for (int j = 1; j <= n; j++)
        if ((r[j].mask >> i) & 1) r[j].val *= -1;
    }
  }
  printf("%lld", s);
  return 0;
}
