#K80482. Flower Grid Generator

    ID: 35540 Type: Default 1000ms 256MiB

Flower Grid Generator

Flower Grid Generator

You are given four integers n, m, k, and t, where:

  • n is the number of rows of a grid,
  • m is the number of columns,
  • k is the number of different flower types, and
  • t is a rotation parameter (not affecting the pattern in this version).

Your task is to generate an n × m grid such that each cell is filled with a flower type numbered from 1 to k. The grid must be filled in such a way that no two adjacent cells (either in the same row or via the implied pattern) share the same flower type. A simple way to achieve this is to assign the flower type for the cell at row i and column j using the formula:

$$flower(i,j) = ((i + j) \bmod k) + 1$$

where indices i and j are 0-indexed. The parameter t is provided as part of the input but does not affect the generation process in this problem.

Print the grid by outputting each row in a new line with the numbers separated by a space.

inputFormat

The input is read from standard input (stdin) and consists of a single line with four space-separated integers: n m k t.

outputFormat

Output the generated grid to standard output (stdout). Each of the n rows should be printed on a new line, with m integers separated by a single space representing the flower types.

## sample
4 3 3 1
1 2 3

2 3 1 3 1 2 1 2 3

</p>