Settlement Office

Report each row or column sum in a grid holding x plus y, zeroing that row or column after each query.

Easy3Hash mapMathInterviewNo attempts yetTime limit1sMemory limit256 MB

Problem

Garison and Andreson work at a settlement office and want to predict the future. They are given a large n×nn \times n square grid. At the start the element at (x,y)(x, y) holds x+yx + y (1x,yn1 \le x, y \le n).

Two kinds of queries arrive.

  • R r: print the sum of every value in row rr, then set all of row rr to 0.
  • C c: print the sum of every value in column cc, then set all of column cc to 0.

Write a program that reports the result of each query in order.

Input

The first line has the grid size nn and the number of queries qq (1n1061 \le n \le 10^6, 1q1051 \le q \le 10^5).

Each of the next qq lines has one query, either R r (1rn1 \le r \le n) or C c (1cn1 \le c \le n).

Output

Print the result of the ii-th query on the ii-th line (1iq1 \le i \le q).