#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const LL ShiftAll = 1.5e17;

/*LL GetXorPositions(LL x, LL y) {
  if (!y) { return x; }
  if (!(y & (y - 1))) { return x ^ (x + y); }

  int low_bit = 0;
  while (!((y >> low_bit) & 1)) { ++low_bit; }

  LL answer = 0;
  for (int bit = 0; bit < 60; ++bit) {
    if ((y >> bit) & 1) { continue; }
    if ((1LL << bit) <= y) { continue; }

    LL overflow_bound = (1LL << bit) - (x & ((1LL << bit) - 1));
    LL my_y = 0;
    //debug(bit, overflow_bound, low_bit);
    bool fail = false;
    for (int b = bit - 1; b > low_bit; --b) {
      bool ov_bit = ((overflow_bound >> b) & 1);
      bool y_bit = ((y >> b) & 1);
      if (ov_bit && !y_bit) { fail = true; break; }
      my_y |= ((LL)ov_bit << b);
    }

    int num_over = (my_y >= overflow_bound);
    num_over += ((my_y ^ (1LL << low_bit)) >= overflow_bound);
    if (!fail && num_over == 1) {
      answer += 1LL << bit;
    }
  }
  return answer;
}

LL BruteXorPositions(LL x, LL y) {
  LL ans = 0;
  for (LL i = 0; i <= y; ++i) {
    if ((y & i) == i) {
      ans ^= (x + i);
    }
  }
  return ans;
}*/

bool ParityXorNotExceeding(LL x, LL y, LL max_val) {
  if (x > max_val) { return 0; }

  int low_bit = 0;
  while (!((y >> low_bit) & 1)) { ++low_bit; }

  max_val -= x;
  for (int bit = 60; bit > low_bit; --bit) {
    bool max_bit = ((max_val >> bit) & 1);
    bool y_bit = ((y >> bit) & 1);
    if (max_bit && !y_bit) {
      return false;
    }
  }

  return !((max_val >> low_bit) & 1);
}

int32_t main() {
#ifndef LOCAL
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
#endif

  /*LL x, y, m;
  while (cin >> x >> y >> m) {
    cout << ParityXorNotExceeding(x, y, m) << "\n";
  }
  return 0;*/

  const LL kLarge = 1LL << 58;

  int N;
  cin >> N;
  vector<pair<LL, LL>> values;

  auto TotalParity = [&](LL bound) {
    bool ans = false;
    for (auto &val : values) {
      ans ^= ParityXorNotExceeding(val.st, val.nd, bound);
    }
    return ans;
  };

  for (int i = 0; i < N; ++i) {
    LL x, y;
    cin >> x >> y;
    values.emplace_back(x + kLarge, y + kLarge * 2);
  }

  LL L = 0;
  while (true) {
    LL R = L + kLarge;
    if (!TotalParity(R)) {
      L += kLarge;
      continue;
    }

    while (R - L > 1) {
      const int M = (L + R) / 2;
      if (TotalParity(M)) {
        R = M;
      } else {
        L = M;
      }
    }
    cout << R - kLarge << "\n";
    break;
  }
}



Measured memory_bytes: 2420