cho.sh
Notes
Loading...

Find Marble Positions and Velocities

Time limit

2s

Memory limit

128 MB

Problem

There are N marbles on a table. Each marble moves at a constant velocity along a line parallel to the x-axis. Their y-coordinates are all different, so the marbles never collide, and their initial x-coordinates are also all different.

N+1 photographs were taken at equal time intervals. Each photograph lists only the x-coordinates of the N marbles visible at that moment. Since all marbles look identical, a photograph does not tell which coordinate belongs to which marble.

Given the photographs in order, determine every marble's initial x-coordinate and its velocity, where velocity means the change in x-coordinate during one photograph interval.

Input

The first line contains the number of marbles N. (1 <= N <= 500)

The next N+1 lines describe the photographs taken at times 0 through N, in order. Each line contains N integers: the x-coordinates of the marbles in that photograph.

Every x-coordinate is an integer whose absolute value does not exceed 2,000,000,000.

Output

Print N lines. Each line must contain one marble's initial x-coordinate and velocity, separated by a space.

Output the marbles in increasing order of their initial x-coordinate. The velocity is the amount by which the x-coordinate changes during one photograph interval.