Score : 1000 points
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:
After the operations, N lamps (x_1, y_1), \cdots, (x_N, y_N) are on, and all other lamps are off. Find X.
Input is given from Standard Input in the following format:
N x_1 y_1 : x_N y_N
Print X.
4 -2 1 -2 2 0 1 1 0
-1
The following picture shows one possible sequence of operations: