Settlement Office
InterviewTime limit1sMemory limit256 MB
Report each row or column sum in a grid holding x plus y, zeroing that row or column after each query.
Problem
Garison and Andreson work at a settlement office and want to predict the future. They are given a large square grid. At the start the element at holds ().
Two kinds of queries arrive.
R r: print the sum of every value in row , then set all of row to 0.C c: print the sum of every value in column , then set all of column to 0.
Write a program that reports the result of each query in order.
Input
The first line has the grid size and the number of queries (, ).
Each of the next lines has one query, either R r () or C c ().
Output
Print the result of the -th query on the -th line ().