#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const int N = 300001;
const int Base = 61;
int _max(int x, int y) { return x > y ? x : y; }
int _min(int x, int y) { return x < y ? x : y; }
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
void put(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) put(x / 10);
  putchar(x % 10 + '0');
}
long long bin[62], a[N];
vector<int> q[62], g[62];
int main() {
  int n = read();
  bin[0] = 1;
  for (int i = 1; i <= Base; i++) bin[i] = bin[i - 1] << 1;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = read();
    long long id = read();
    bool bk = 0;
    for (int j = Base; j >= 0; j--)
      if (id & bin[j]) {
        q[j].push_back(i);
        if (!bk) bk = 1, g[j].push_back(i);
      }
    sum += a[i];
  }
  long long ans = 0;
  for (int i = 0; i <= Base; i++) {
    long long hh = 0;
    for (int j = 0; j < g[i].size(); j++) hh += a[g[i][j]];
    if ((sum > 0 && hh > 0) || (sum < 0 && hh < 0)) {
      ans += bin[i];
      for (int j = 0; j < q[i].size(); j++) a[q[i][j]] = -a[q[i][j]];
    }
  }
  put(ans), puts("");
  return 0;
}
