Manhattan Positioning System

Given beacons with known grid positions and Manhattan distances to an unknown receiver, decide whether the receiver position is unique, ambiguous, or impossible.

Medium6GeometryMathImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

The Manhattan Positioning System (MPS) is a variant of GPS built for large cities. MPS treats every position as a lattice point on a regular two dimensional grid, and writes a position as a pair of integers (X,Y)(X, Y).

To find its own position, an MPS receiver first measures the distance to a number of beacons. Every beacon has a known, fixed position. MPS signals travel along the streets of the city, that is along the XX and YY axes only, and never diagonally across a block. A receiver at (XR,YR)(X_R, Y_R) that measures the distance to a beacon at (XB,YB)(X_B, Y_B) therefore reads the Manhattan distance XRXB+YRYB|X_R - X_B| + |Y_R - Y_B|.

You are given the positions of several beacons and the measured distance from the receiver to each of them. Determine the position of the receiver. The receiver sits on an integer grid point, because MPS does not support fractional coordinates.

Input

The first line contains an integer NN, the number of beacons (1N10001 \le N \le 1000). Each of the next NN lines contains three integers XiX_i, YiY_i, DiD_i with 106Xi,Yi106-10^6 \le X_i, Y_i \le 10^6 and 0Di4×1060 \le D_i \le 4 \times 10^6. The pair (Xi,Yi)(X_i, Y_i) is the position of beacon ii, and DiD_i is the Manhattan distance between the receiver and beacon ii.

No two beacons have the same position.

Output

If exactly one receiver position agrees with the input, print one line with two integers XRX_R and YRY_R, the position of the receiver.

If more than one receiver position agrees with the input, print one line with the word uncertain.

If no receiver position agrees with the input, print one line with the word impossible.