#K68897. Apply Rectangle Coloring Instructions

    ID: 32966 Type: Default 1000ms 256MiB

Apply Rectangle Coloring Instructions

Apply Rectangle Coloring Instructions

You are given a grid of size \(m \times n\) initially filled with zeros. You will receive \(k\) rectangle coloring instructions. Each instruction consists of five integers \(r_1, c_1, r_2, c_2, color\), indicating that you should color every cell in the sub-grid from row \(r_1\) to \(r_2\) and column \(c_1\) to \(c_2\) (1-indexed) with the given \(color\). Note that later instructions may overwrite previous colors. Output the final grid after processing all instructions.

inputFormat

The first line contains two integers m and n representing the number of rows and columns of the grid. The second line contains an integer k, the number of coloring instructions. Each of the following k lines contains five integers: r1, c1, r2, c2, and color, describing a rectangle to be colored.

outputFormat

Output the final grid after performing all coloring instructions. Each of the m lines should contain n space-separated integers representing the colors in that row.## sample

5 5
1
1 1 3 3 2
2 2 2 0 0

2 2 2 0 0 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0

</p>