The grand final of the Tengo-lengo-tengo World Cup is about to begin! The decisive match will be played between Altos and Bahia, and the line to enter the stadium is pure chaos.
The line is made entirely of fans of the two teams. As tradition dictates, whenever an Altos fan is standing before (closer to the stadium entrance than) a Bahia fan, we say there is a banter happening between them.
Mathematically, if we view the line as a string $$$S$$$ made of the letters 'A' and 'B', a banter is formed by each pair of indices $$$(i, j)$$$ such that $$$i \lt j$$$, where $$$S[i]$$$ is an Altos fan ('A') and $$$S[j]$$$ is a Bahia fan ('B').
The stadium organization recorded $$$Q$$$ events in the line, which can be of $$$4$$$ types:
Your task is to compute the total number of banters happening in the line immediately after each event.
The first line of the input contains an integer $$$Q$$$ ($$$1 \leq Q \leq 10^{6}$$$), representing the number of events.
The next $$$Q$$$ lines describe the events. Each line starts with an integer $$$T$$$ ($$$1 \leq T \leq 4$$$):
It is guaranteed that operations of type $$$3$$$ and $$$4$$$ are never called when the line is empty.
For each query, print a single integer on one line: the number of banters happening in the line at the current moment.
12 A
0
51 A1 B1 B1 A1 B
0 1 2 2 4
51 A2 B2 A34
0 0 1 1 0
Explanation for example 2
In the second example, after each event the line becomes, respectively, A, AB, ABB, ABBA, and ABBAB. The numbers of banters in these lines are $$$0$$$, $$$1$$$, $$$2$$$, $$$2$$$, and $$$4$$$, because each banter corresponds to an A that appears before a B.
Explanation for example 3
In the third example, after each event the line becomes, respectively, A, BA, ABA, AB, and B. Thus, the numbers of banters are $$$0$$$, $$$0$$$, $$$1$$$, $$$1$$$, and $$$0$$$.
| Name |
|---|


