logo AlgoBeat OnlineJudge
登录 注册

#206132. [NEERC 2015] Adjustment Office

内存限制:256 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Garrison and Anderson are working in a company named “Adjustment Office”. In competing companies workers change the reality, in this company they try to predict the future.

They are given a big square board . Initially in each cell of this board the value of is written ). They know that in the future there will be two types of queries on the board:

  • “R ” — sum up all values in row , print the result and set all values in row to zero;
  • “C ” — sum up all values in column , print the result and set all values in column to zero.

They have predicted what queries and results there will be. They need to ensure that they have correctly predicted the results. Help them by computing the results of the queries.

输入格式

The first line of the input contains two integers and , ) — the size of the square and the number of queries.

Each of the next lines contains the description of the query. Each query is either “R ” ) or “C ” ).

输出格式

The output file shall contain lines. The - th line shall contain one integer — the result of the - th query.

样例

样例输入 1

3 7
R 2
C 3
R 2
R 1
C 2
C 1
R 3

样例输出 1

12
10
0
5
5
4
0

数据范围与提示

Time limit: 1 s, Memory limit: 256 MB.