CF1998A.Find K Distinct Points with Fixed Center

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Find K Distinct Points with Fixed Center

I couldn't think of a good title for this problem, so I decided to learn from LeetCode.— Sun Tzu, The Art of War

You are given three integers xcx_c, ycy_c, and kk (100xc,yc100-100 \leq x_c, y_c \leq 100, 1k10001 \leq k \leq 1000).

You need to find kk distinct points (x1,y1x_1, y_1), (x2,y2x_2, y_2), \ldots, (xk,ykx_k, y_k), having integer coordinates, on the 2D coordinate plane such that:

  • their center^{\text{∗}} is (xc,ycx_c, y_c)
  • 109xi,yi109-10^9 \leq x_i, y_i \leq 10^9 for all ii from 11 to kk

It can be proven that at least one set of kk distinct points always exists that satisfies these conditions.

^{\text{∗}}The center of kk points (x1,y1x_1, y_1), (x2,y2x_2, y_2), \ldots, (xk,ykx_k, y_k) is $\left( \frac{x_1 + x_2 + \ldots + x_k}{k}, \frac{y_1 + y_2 + \ldots + y_k}{k} \right)$.

Input

The first line contains tt (1t1001 \leq t \leq 100) — the number of test cases.

Each test case contains three integers xcx_c, ycy_c, and kk (100xc,yc100-100 \leq x_c, y_c \leq 100, 1k10001 \leq k \leq 1000) — the coordinates of the center and the number of distinct points you must output.

It is guaranteed that the sum of kk over all test cases does not exceed 10001000.

Output

For each test case, output kk lines, the ii-th line containing two space separated integers, xix_i and yiy_i, (109xi,yi109-10^9 \leq x_i, y_i \leq 10^9) — denoting the position of the ii-th point.

If there are multiple answers, print any of them. It can be shown that a solution always exists under the given constraints.

Note

For the first test case, $\left( \frac{10}{1}, \frac{10}{1} \right) = (10, 10)$.

For the second test case, $\left( \frac{-1 + 5 - 4}{3}, \frac{-1 -1 + 2}{3} \right) = (0, 0)$.

Samples

4
10 10 1
0 0 3
-5 -8 8
4 -5 3
10 10
-1 -1
5 -1
-4 2
-6 -7
-5 -7
-4 -7
-4 -8
-4 -9
-5 -9
-6 -9
-6 -8
1000 -1000
-996 995
8 -10

在线编程 IDE

建议全屏模式获得最佳体验