In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
A knight moves on an infinite chessboard. Each move it can perform is described by a pair of integers - a pair indicates that a move from the square (with coordinates)
to the square
or
is possible. Each knight has a prescribed set of such pairs, describing the moves this knight can make. For each knight we assume that not all squares this knight can move to from square
are collinear.
We say two knights are equivalent, if they can reach exactly the same squares starting from the square (by making many moves, perhaps). (Let us point out that equivalent knights may reach these squares in different number of moves). It can be shown that for every knight there exists an equivalent one whose moves are described by only two pairs of numbers.
Write a programme that:
In the first line of the standard input one integer is written, denoting the number of pairs describing the knight's moves,
. In the following
lines pairs of integers representing the knight's moves are written, one pair per line. In each of these lines two integers
and
separated by a single space are written,
. We assume that
.
In the first line of the standard output two integers and
separated by a single space should be written,
. In the second line two integers
and
separated by a single space should be written,
. The above integers should satisfy the condition that a knight whose moves are described by pairs
) and
is equivalent to the knight described in the input data.
For the following input data:
3 24 28 15 50 12 21
the correct answer is:
468 1561 2805 9356
or:
3 0 0 1
Task author: Wojciech Guzicki.