Knight Polygon
시간 제한1초메모리 제한1024 MB
각 분수 p/q에 대해 인접한 꼭짓점이 나이트 이동 관계이고 넓이가 정확히 p/q인 단순 격자 다각형을 출력하거나, 존재하지 않으면 -1을 출력한다.
문제
Two points and are considered to be a knight-move apart if exactly one of the following conditions holds:
- and
- and
Notice that this definition closely matches how a knight moves in chess. For example, here are three pairs of points that are a knight-move apart:

You are given integers and . Find a simple lattice polygon whose area is , where each pair of adjacent vertices is a knight-move apart, or state that no such polygon exists.
A polygon is simple if there are exactly two edges touching each vertex, and no two edges of the polygon intersect except at its vertices. A polygon is a lattice polygon if the coordinates of each of its vertices are integers.
입력
The first line of the input contains a single integer () --- the number of test cases. The description of the test cases follows.
Each test case consists of a single line containing two integers and () --- the numerator and denominator of the desired area, respectively.
출력
For each test case, if there is no solution, output a single integer .
Otherwise, the first line of output for each test case should contain a single integer () --- the number of vertices in your polygon.
The next lines of output should each contain two integers and () --- the vertices of your polygon in either clockwise or counterclockwise order.
Your polygon should be simple, have an area of , and each pair of adjacent vertices should be a knight-move apart.
If there are multiple solutions, print any.
힌트
Here is the polygon described by the output of the first test case, with an area of :

Here is the polygon described by the output of the third test case, with an area of :

For the second and fourth test cases, we can show that no valid polygon exists.