#arc175e. E - Three View Drawing

E - Three View Drawing

Score: 800800 points

问题陈述

将边长为 NN 的立方体分割成 N3N^3 个更小的立方体,每个小立方体的边长为 11,并从中选择 KK 个这样的小立方体。构建一种选择方式,使得从立方体的三个面垂直方向观察时,所有 KK 个被选中的小立方体都是可见的,并且呈现出相同的形状。

为了精确地表述问题,我们将分割后每个小立方体与一个整数三元组 (xi,yi,zi)(x_i, y_i, z_i) 相关联。

构建并打印一组 KK 个整数三元组 (xi,yi,zi)(x_i, y_i, z_i),满足以下条件:

  • 0xi,yi,zi<N0 \leq x_i, y_i, z_i < N
  • $\left\lbrace (x_i, y_i) \, \middle| \, 1 \le i \le K \right\rbrace = \left\lbrace (y_i, z_i) \, \middle| \, 1 \le i \le K \right\rbrace = \left\lbrace (z_i, x_i) \, \middle| \, 1 \le i \le K \right\rbrace$
  • 上述集合中包含 KK 个元素。也就是说,对于 iji \neq j(xi,yi)(xj,yj)(x_i, y_i) \neq (x_j, y_j)

可以证明,对于满足约束条件的任何输入,都存在一个解决方案。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

Divide a cube with a side length of NN into N3N^3 smaller cubes, each with a side length of 11, and select KK of these smaller cubes. Construct one way to select them so that, when viewed from any of the three directions perpendicular to the faces of the cubes, all KK selected cubes are visible and appear in the same shape.

To formulate the problem precisely, we associate each smaller cube after division with a triple of integers (xi,yi,zi)(x_i, y_i, z_i).

Construct and print one set of KK triples of integers (xi,yi,zi)(x_i, y_i, z_i) that satisfy the following conditions.

  • 0xi,yi,zi<N0 \leq x_i, y_i, z_i < N
  • $\left\lbrace (x_i, y_i) \, \middle| \, 1 \le i \le K \right\rbrace = \left\lbrace (y_i, z_i) \, \middle| \, 1 \le i \le K \right\rbrace = \left\lbrace (z_i, x_i) \, \middle| \, 1 \le i \le K \right\rbrace$
  • The set mentioned in the previous item has KK elements. That is, (xi,yi)(xj,yj)(x_i, y_i) \neq (x_j, y_j) for iji \neq j.

It can be shown that a solution exists for any input satisfying the constraints.

Constraints

  • All input values are integers.
  • 1N5001 \leq N \leq 500
  • 1KN21 \leq K \leq N^2

Input

The input is given from Standard Input in the following format:

NN KK

Output

Print your answer in the following format:

x1x_1 y1y_1 z1z_1

x2x_2 y2y_2 z2z_2

\vdots

xKx_K yKy_K zKz_K

If multiple solutions exist, any of them will be accepted.

Sample Input 1

3 3

Sample Output 1

0 0 0
1 1 1
2 2 2

Sample Input 2

2 4

Sample Output 2

0 0 1
0 1 0
1 0 0
1 1 1

Sample Input 3

1 1

Sample Output 3

0 0 0