#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 -th carriage, he wants to know the total number of students in the first carriages. However, he does not have the habit of turning back. This means that each time he asks a question, will always be greater than the previous value.
Input Format
The first line contains two integers, and , representing the total number of train carriages and the number of events, respectively.
The next lines describe the 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 , indicating that the grade director is now at the -th carriage. - If the letter is
B, it is followed by two numbers and , indicating that students board the -th carriage. - If the letter is
C, it is followed by two numbers and , indicating that students alight from the -th carriage.
The total number of students will not exceed .
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 of the data, , with at least A events.
For of the data, , with at least A events.