You are given an
R j
- multiply every number in row by .C j
- multiply every number in column by .I
- increment every number in the grid by .
After all
Constraints
Subtask 1 [30%]
There are no increment (type I
) updates.
Subtask 2 [70%]
No additional constraints.
Input Specification
The first line contains two space-separated integers,
The next
R j
- multiply every number in row by .C j
- multiply every number in column by .I
- increment every number in the grid by .
Output Specification
The sum of the numbers in the grid after all
Note: These numbers may not fit within a 32-bit integer type.
Sample Input
5 4
R 3
I
C 1
R 4
Sample Output
-19 25
Explanation for Sample
Here is the state of the grid after each update:
Initially, every number in the grid is equal to
The first update, R 3
, multiplies every number in row
The second update, I
, increments every number in the grid by
The third update, C 1
, multiplies every number in column
The fourth update, R 4
, multiplies every number in row
Finally, the sum of all the numbers in the grid is -19 25
.
Comments