#P3421. [POI 2005] SKO-Knights

[POI 2005] SKO-Knights

Description

A knight moves on an infinite chessboard. Each move it can perform is described by a pair of integers (a,b)(a,b), meaning the knight can move from (x,y)(x,y) to (x+a,y+b)(x+a,y+b) or to (xa,yb)(x-a,y-b). Each knight has a set of such move descriptions, representing the moves it can perform. We assume that all positions reachable by a knight starting from (0,0)(0,0) are not collinear.

We say two knights are equivalent if they can reach exactly the same set of coordinates from (0,0)(0,0). (Note that the same knight may reach those squares using different sequences of moves.) It can be shown that for every knight there exists an equivalent knight whose moves can be described by only two pairs of integers.

Your task is to read a set of move descriptions for a knight, determine two pairs of integers that describe an equivalent knight, and output these two pairs.

Input Format

The first line contains an integer nn (3n1003\le n\le 100), the number of move pairs.
Each of the next nn lines contains a pair of integers aia_i and bib_i separated by a space, where 100ai,bi100-100\le a_i,b_i\le 100 and (ai,bi)(0,0)(a_i,b_i)\neq(0,0).

Output Format

Output two lines.
The first line contains two integers aa and bb separated by a space.
The second line contains two integers cc and dd separated by a space.

These integers must satisfy 10000a,b,c,d10000-10000\le a,b,c,d\le 10000, and the two output pairs must describe a knight equivalent to the knight described in the input.

3
24 28
15 50
12 21
3 0
0 1

Hint

Translated by ChatGPT 5