Color matrix#10444

Color matrix

1 second
256 megabytes
Medium

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.

Input

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.

Output

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.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Note

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.

Scoring

  1. ( points): k=1;

  2. ( points): k=2;

  3. ( points): k=3;

  4. ( points): k=4;

  5. ( points): is odd;

  6. ( points): no additional constraints.