#K74942. Grid Increment Operations
Grid Increment Operations
Grid Increment Operations
You are given a grid of size (N \times M) initially filled with zeros. You will receive (Q) operations. Each operation is represented by four integers (a, b, c, d) and indicates that you should increment every cell in the rectangle defined by its top-left corner ((a, b)) and bottom-right corner ((c, d)) (using 1-indexed coordinates) by 1.
Your task is to process all the operations and output the final state of the grid. Use standard input (stdin) for input and standard output (stdout) for your output.
inputFormat
The first line contains three integers (N), (M), and (Q) representing the number of rows, columns, and operations respectively (with (1 \leq N, M, Q \leq 1000)). Each of the next (Q) lines contains four integers (a, b, c, d) ((1 \leq a \leq c \leq N), (1 \leq b \leq d \leq M)), describing an operation on the grid.
outputFormat
Output (N) lines, each containing (M) space-separated integers representing the final grid after all operations have been applied.## sample
3 3 2
1 1 2 2
2 2 3 3
1 1 0
1 2 1
0 1 1
</p>