3 4 2 1 1 2 3 5 2 2 3 4 -2
Applying both rectangle updates leaves the final grid shown by the sample output.
5 5 5 0 5 3 3 -2 0 -2 -2 -2
2 2 1 1 1 2 2 7
The single update covers the entire grid, so every cell becomes 7.
7 7 7 7
3 3 3 1 1 1 1 4 2 2 3 3 1 1 3 3 3 -2
Each cell receives the sum of the updates whose rectangles include it.
4 0 -2 0 1 -1 0 1 -1
Start with an n×mn \times mn×m grid of zeros. Apply qqq rectangle increments, then print the final grid.