#C4915. Fill the Canvas

    ID: 48506 Type: Default 1000ms 256MiB

Fill the Canvas

Fill the Canvas

You are given a canvas with n rows and m columns, and k different colors numbered from 1 to \(k\). Your task is to fill the canvas with colors such that no two adjacent cells (cells sharing a common side) have the same color.

The filling should be done in a row-major order (from top to bottom, and left to right within a row). For each cell, choose the smallest color number (from 1 to \(k\)) which is not used by its already filled adjacent cells (above and to the left).

If the canvas is of size 1x1, simply output the only available color.

inputFormat

The input consists of a single line with three space-separated integers \(n\), \(m\), and \(k\), where:

  • \(n\) is the number of rows of the canvas,
  • \(m\) is the number of columns, and
  • \(k\) is the number of available colors.

outputFormat

Output the filled canvas as \(n\) lines. Each line should contain \(m\) space-separated integers representing the color indices in that row.

## sample
3 4 3
1 2 1 2

2 1 2 1 1 2 1 2

</p>