Given a field of size n \times m, consisting of rows and columns.
Kozak Vus wants to color the cells using the minimum number of colors. However, he wants to ensure that no two cells of the same color are exactly units apart in terms of Manhattan distance.
Recall that the Manhattan distance between two cells (x_1, y_1) and (x_2, y_2) is calculated as |x_1-x_2|+|y_1-y_2|.
Determine the minimum number of colors needed to achieve this, and provide the colored field as output.
The first line contains three integers , , (1 \leq n, m, k \leq 100, k < \min(n, m)) — representing the number of rows, columns, and the specified Manhattan distance.
On the first line, output the minimum number of colors required.
For each of the following lines, output numbers — representing the color numbers assigned to each cell in the table (0 \leq c_{i,j} \leq t-1).
If multiple valid colorings exist, any one of them can be provided.
Example 1
Example 2
In the first example, positions and are both colored with , while positions and are colored with . The Manhattan distance between positions and is |1-1|+|1-2|=1. Since k=1, these two positions must have different colors. However, the distance between positions and is |1-2|+|2-1|=2, allowing them to share the same color.
( points): k=1;
( points): k=2;
( points): k=3;
( points): k=4;
( points): is odd;
( points): no additional constraints.