Problem:
Score : 1000 points

Problem Statement

There is an infinitely large triangular grid, as shown below.
Each point with integer coordinates contains a lamp.

Initially, only the lamp at (X, 0) was on, and all other lamps were off.
Then, Snuke performed the following operation zero or more times:

Choose two integers x and y.
Toggle (on to off, off to on) the following three lamps: (x, y), (x, y+1), (x+1, y).

After the operations, N lamps (x_1, y_1), \cdots, (x_N, y_N) are on, and all other lamps are off.
Find X.

Constraints

1 \leq N \leq 10^5

-10^{17} \leq x_i, y_i \leq 10^{17}

(x_i, y_i) are pairwise distinct.

The input is consistent with the statement, and you can uniquely determine X.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
:
x_N y_N

Output

Print X.

Sample Input 1

4
-2 1
-2 2
0 1
1 0

Sample Output 1

-1

The following picture shows one possible sequence of operations:

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void debug(vec &v) {
	int n = v.size();
	rep(i, n) {
		if (i > 0)cout << " ";
		cout << v[i];
	}
	cout << endl;
}

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

int calc(ll y, ll x, int sta = 59) {
	if (x <= 0)return 0;
	if (y < 0) {
		ll memo = 1;
		while (memo < -y)memo *= 2;
		ll d = x / memo;
		int res = 0;
		if (d % 2)res ^= calc(y + memo, memo);
		ll r = x % memo;
		res ^= calc(y + memo, r);
		return res;
	}
	if (y == 0)return 1;
	ll memo = 1;
	int chk;
	for (int i = sta; i >= 0; i--) {
		ll k = (ll)1 << i;
		if (k <= y) {
			memo = k; chk = i - 1; break;
		}
	}
	while (memo * 2 <= y)memo *= 2;
	if (memo <= x) {
		int res = calc(y - memo, x - memo,chk);
		if (memo == y)res ^= 1;
		return res;
	}
	else {
		return calc(y - memo, x,chk);
	}
}
void solve() {
	int n; cin >> n;
	vector<ll> x(n), y(n);
	rep(i, n) {
		cin >> x[i] >> y[i];
	}
	ll le = -(1e+17) - 1; ll ri = -le;
	while (ri - le > 1) {
		ll mid = (le + ri) / 2;
		int res = 0;
		rep(i, n) {
			ll dy = y[i];
			ll dx = mid - x[i] + 1;
			res ^= calc(dy, dx);
		}
		if (res)ri = mid;
		else le = mid;
	}
	cout << ri << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(17);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}