#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using pss = pair<string, string>;   using pis = pair<int, string>;   const int maxn = 300300;   int n;   LL val[maxn], mask[maxn], sum;   signed main() {     while (cin >> n) {       sum = 0;       for (int i = 1; i <= n; i++) {         cin >> val[i] >> mask[i];         sum += val[i];       }       for (int i = 1; i <= n; i++) {         if (sum < 0) {           val[i] = -val[i];         }       }       LL ret = 0;       for (int k = 0; k < 62; k++) {         LL tot = 0;         for (int i = 1; i <= n; i++) {           if (mask[i] == (1LL << k)) {             tot += val[i];           }         }         if (tot > 0) ret |= (1LL << k);         for (int i = 1; i <= n; i++) {           if ((1LL << k) & mask[i]) {             mask[i] ^= (1LL << k);             if (tot > 0) {               val[i] = -val[i];             }           }         }       }       cout << ret << endl;     }     return 0;   }   