#C3412. Grid Operations
Grid Operations
Grid Operations
You are given a grid of size \( N \times M \) filled with integers. You are also given \( Q \) operations. Each operation is described by six integers: \( op\_type, x_1, y_1, x_2, y_2, val \). The coordinates are 1-indexed.
If \( op\_type = 1 \), then you should add \( val \) to all cells in the subgrid defined by the top-left \( (x_1, y_1) \) and bottom-right \( (x_2, y_2) \). If \( op\_type = 2 \), then you should set every cell in the subgrid to \( val \).
After performing all operations sequentially, output the final state of the grid.
inputFormat
The first line contains two integers \( N \) and \( M \), the number of rows and columns respectively.
The next \( N \) lines each contain \( M \) integers representing the initial grid configuration.
The following line contains a single integer \( Q \), the number of operations.
The next \( Q \) lines each contain 6 integers: \( op\_type, x_1, y_1, x_2, y_2, val \) describing an operation.
outputFormat
Print the final grid after performing all the operations. Each of the \( N \) lines should contain \( M \) integers separated by a space.
## sample2 2
1 2
3 4
3
1 1 1 1 1 2
2 2 2 2 2 5
1 1 1 2 2 1
4 3
4 6
</p>