is part of the robotics team in his school. During one of the meetings after school, a sketchy person was wandering around and came into the robotics room. This person sees a storage bin full of the VEX Starstruck jacks and immediately becomes obsessed with them. sees this and tells him that he can disassemble one of the jacks by squeezing them. The person does so, and the jack breaks into pieces.
Due to the sketchy nature of this person and his obsession with the jacks, he begins to take ~K~ jacks from the storage bin one by one, and squeezing them. This frenzied period continues for ~N~ seconds.
Every second, the person does one of two possible actions:
T: Takes one jack out from the storage bin, and places it on the table.
B q: Breaks each jack or piece that's currently on the table into
qpieces, and puts them on the floor. When the table is empty, transfer all the pieces on the floor back onto the table.
needs to gather all these pieces so that he can fix them by gluing them together at home. After a few minutes, he realizes that the number of pieces is growing rapidly. In order to
prevent integer overflow allow to finish the work that was assigned by his English teacher, he decides that he will consider a jack "dust" if the jack is broken into strictly greater than ~D~ pieces, and he will not be gluing them back together.
needs to figure out how many pieces each jack has been broken into, to assist him in gluing together the jacks that the person broke.
Sinceis quite busy building the robot, can you help him figure this out?
The first line will contain the integers ~N~, ~K~ and ~D~, representing the number of modifications done by the sketchy person, the number of jacks in the storage bin, and the dust threshold respectively.
The next ~N~ lines represent the operations. Each line will contain either just a character
T, or a character followed by an integer
B q, where ~q~ is the integer.
For all subtasks:
~1 \le K \le N~
~1 \le D \le 10^6~
~1 \le q \le 1000~, for each ~q~
Subtask 1 [50%]
~1 \le N \le 100~
Subtask 2 [50%]
~1 \le N \le 10^5~
Output the number of pieces each jack has been broken into, in the order they were taken out of the storage bin.
If a jack has been considered as dust, output
7 4 5 T T B 2 B 3 T B 4 T
dust dust 4 1
The person did ~7~ operations on the ~4~ jacks that were in the storage bin, and will consider any jacks that got broken up into more than ~5~ pieces as "dust".
- The person takes out a jack from the bin and puts it on the table.
- He takes out another jack. (Same operation as above)
- He breaks each of the 2 jacks into 2 pieces, resulting in ~2~ broken pieces for the first jack and ~2~ broken pieces for the second jack.
- He then breaks each piece into 3 new pieces, resulting in ~6~ broken pieces for the first jack and ~6~ broken pieces for the second jack.
- He takes out another jack.
- He then breaks each piece into 4 new pieces, resulting in ~24~ broken pieces for the first jack, ~24~ broken pieces for the second jack, and 4 broken pieces for the third jack.
- He takes out another jack.
In the end, he took out 4 jacks, the first 2 were broken into ~24~ pieces each and therefore considered as "dust" by . The third jack was broken into ~4~ pieces, and the fourth jack was not broken, therefore it remains as ~1~ piece.