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 <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
typedef long long LL;
const int MAXN = 1e5 + 10;

LL x[MAXN], y[MAXN];
int main() {
  int n;
  scanf("%d", &n);

  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", x + i, y + i);
  }

  LL y0 = -((1ll << 60) - 1);
  LL x0 = 0;
  
  for (int i = 61; i >= 0; i--) {
    LL x1 = x0 + (1ll << i);

    int cnt = 0;
    for (int j = 1; j <= n; j++) {
      if (x[j] <= x1 && !((x1 - x[j]) & ~(y[j] - y0))) cnt ^= 1;
    }

    if (cnt) x0 = x1;
  }

  printf("%lld\n", x0 + y0);
  
}