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