Running in the Plane
시간 제한1초메모리 제한1024 MB
격자점 집합이 주어질 때, 원점에서 출발하는 보행이 모든 점을 한 번씩 지나도록 하는 최소 크기의 정수 이동 벡터 집합을 구한다.
문제
You are given a set of points in the plane. All coordinates of are integers.
A set of 2-dimensional vectors is called a good set of if it satisfies the following:
-
There exists a nonempty finite sequence of points in the plane such that
- .
- For all points in , there exists an integer () such that .
- For all integers (), the vector is in .
-
For all integers (), two numbers and are integers between and inclusive.
Find any good set of minimum size.
입력
The input consists of multiple test cases. The first line contains an integer — the number of test cases. The description of the test cases follows. For each test case:
- The first line of the test case contains an integer — the number of points in .
- The -th of the next lines contains two integers and — the coordinates of each point in .
출력
For each test case:
- Let be a minimum-size good set of .
- In the first line of the test case, print an integer — the number of vectors in .
- In the -th of the next lines, print two integers and — the coordinates of each vector.
If there are multiple solutions, print any of them.
It can be proved that, under the constraints of this problem, a good set of with size at most always exists.
제한
- The sum of over all test cases does not exceed .
- ()
- ()
- ()
- ()
힌트
In the first test case, is a minimum-size good set of .
We can take a sequence . Here, the underlined points are in .
In the second test case, is a minimum-size good set of .
We can take a sequence .