#K84537. Taco Garden Operations

    ID: 36441 Type: Default 1000ms 256MiB

Taco Garden Operations

Taco Garden Operations

In this problem, you are given a garden represented as an (N \times M) matrix. Each cell contains an integer representing its color. You are also given (Q) operations. Each operation is described by five integers (r_1, c_1, r_2, c_2, color), where (r_1) and (c_1) denote the top-left coordinates and (r_2) and (c_2) denote the bottom-right coordinates (all 1-indexed) of a submatrix. The operation sets every cell in the specified submatrix to the given color. Operations are applied in the order they are given, and later operations overwrite the colors set by earlier ones. Your task is to simulate these operations and output the final state of the garden.

inputFormat

The input is read from standard input. The first line contains two integers (N) and (M) which represent the number of rows and columns respectively. This is followed by (N) lines, each containing (M) integers that denote the initial state of the garden. The next line contains an integer (Q) representing the number of operations. Following this, there are (Q) lines each containing five integers (r1), (c1), (r2), (c2), and (color) describing an operation.

outputFormat

Output the final state of the garden matrix to standard output. Each row of the matrix should be printed on its own line with the values separated by a space.## sample

3 3
1 2 3
4 5 6
7 8 9
2
1 1 2 2 10
2 2 3 3 20
10 10 3

10 20 20 7 20 20

</p>