Distance to the nearest point

For each of N points, report the Manhattan distance to the nearest other point.

Hard8GeometryDivide and conquerSortingNo attempts yetTime limit2sMemory limit512 MB

Problem

The distance D(A,B)D(A, B) between two points A(x1,y1)A(x_1, y_1) and B(x2,y2)B(x_2, y_2) is defined as follows.

D(A,B)=x1x2+y1y2D(A, B) = |x_1 - x_2| + |y_1 - y_2|

You are given NN points A1,A2,,ANA_1, A_2, \dots, A_N. For each point AiA_i, find the closest point AjA_j among the others and report the distance D(Ai,Aj)D(A_i, A_j).

Input

The first line contains the number of points NN (2N2×1052 \le N \le 2 \times 10^5).

Each of the next NN lines contains the coordinates xx and yy of a point AiA_i, separated by a space (107x,y107-10^7 \le x, y \le 10^7). All coordinates are integers. Two or more points may have exactly the same coordinates, and the distance between such a pair is 00.

Output

For A1A_1 through ANA_N, in the order given in the input, print the distance from that point to its closest point, one per line.