atcoder#WTF19C1. Triangular Lamps Easy

Triangular Lamps Easy

Score : 10001000 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)(X, 0) was on, and all other lamps were off. Then, Snuke performed the following operation zero or more times:

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

After the operations, NN lamps (x1,y1),,(xN,yN)(x_1, y_1), \cdots, (x_N, y_N) are on, and all other lamps are off. Find XX.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1017xi,yi1017-10^{17} \leq x_i, y_i \leq 10^{17}
  • (xi,yi)(x_i, y_i) are pairwise distinct.
  • The input is consistent with the statement, and you can uniquely determine XX.

Input

Input is given from Standard Input in the following format:

NN

x1x_1 y1y_1

::

xNx_N yNy_N

Output

Print XX.

4
-2 1
-2 2
0 1
1 0
-1

The following picture shows one possible sequence of operations: