Garison and Andreson work at a settlement office and want to predict the future. They are given a large n×n square grid. At the start the element at (x,y) holds x+y (1≤x,y≤n).
Two kinds of queries arrive.
R r: print the sum of every value in row r, then set all of row r to 0.
C c: print the sum of every value in column c, then set all of column c to 0.
Write a program that reports the result of each query in order.