#Q118. 「一本通 4.1 练习 1」清点人数

「一本通 4.1 练习 1」清点人数

Description

NK High School organizes students to participate in social practice activities at Wuyun Mountain Village, and as per tradition, they travel by train. Due to the large number of students at NK High School, it is essential to count the number of students accurately before the train departs.

Initially, there are no students on the train. As students begin to board, the grade director starts from the first carriage and walks toward the last. At any time, students may board or alight from any carriage. When the grade director reaches the mm-th carriage, he wants to know the total number of students in the first mm carriages. However, he does not have the habit of turning back. This means that each time he asks a question, mm will always be greater than the previous value.

Input Format

The first line contains two integers, nn and kk, representing the total number of train carriages and the number of events, respectively.

The next kk lines describe the kk events in chronological order. Each line starts with a letter A, B, or C.

  • If the letter is A, it is followed by a number mm, indicating that the grade director is now at the mm-th carriage.
  • If the letter is B, it is followed by two numbers mm and pp, indicating that pp students board the mm-th carriage.
  • If the letter is C, it is followed by two numbers mm and pp, indicating that pp students alight from the mm-th carriage.

The total number of students will not exceed 10510^5.

Output Format

For each A, output a line containing an integer, which is the answer to the grade director's question.

Sample 1

10 7
A 1
B 1 1
B 3 1
B 4 1
A 2
A 3
A 10

0
1
2
3

Constraints and Hints

For 30%30\% of the data, 1n,k1041\le n,k\le 10^4, with at least 30003000 A events.

For 100%100\% of the data, 1n5×105,1k1051\le n\le 5\times 10^5,1\le k\le 10^5, with at least 3×1043\times 10^4 A events.