#C7170. Matrix Submatrix Update Sum

    ID: 51012 Type: Default 1000ms 256MiB

Matrix Submatrix Update Sum

Matrix Submatrix Update Sum

You are given a matrix of size n × m filled with non-negative integers. You are also provided with q operations. Each operation is defined by 5 integers: x1, y1, x2, y2 and v. For every operation, you add the value v to every element in the submatrix defined by the top left corner (x1, y1) and the bottom right corner (x2, y2). After each update, output the sum of all elements in the matrix.

The submatrix area is defined as:

$$ area = (x_{2} - x_{1} + 1)\times(y_{2} - y_{1} + 1) $$

The overall sum is updated as:

$$ current\_sum = current\_sum + area \times v $$

Your task is to implement the solution so that it works correctly for multiple test cases using standard input and output.

inputFormat

The input is given from standard input (stdin) in the following format:

n m q
A11 A12 ... A1m
A21 A22 ... A2m
... 
An1 An2 ... Anm
// Next q lines, each representing one operation:
x1 y1 x2 y2 v
...

Indices for the matrix are zero-indexed.

outputFormat

For each operation, print a single line containing the sum of all elements in the matrix after applying that operation.

## sample
3 3 3
1 2 3
4 5 6
7 8 9
0 0 1 1 10
1 1 2 2 -3
0 0 2 2 5
85

73 118

</p>