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 jacks from the storage bin one by one, and squeezing them. This frenzied period continues for 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 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 , and , 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 lines represent the operations. Each line will contain either just a character
T, or a character followed by an integer
B q, where is the integer.
For all subtasks:
, for each
Subtask 1 [50%]
Subtask 2 [50%]
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 operations on the jacks that were in the storage bin, and will consider any jacks that got broken up into more than 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 broken pieces for the first jack and broken pieces for the second jack.
- He then breaks each piece into 3 new pieces, resulting in broken pieces for the first jack and broken pieces for the second jack.
- He takes out another jack.
- He then breaks each piece into 4 new pieces, resulting in broken pieces for the first jack, 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 pieces each and therefore considered as "dust" by . The third jack was broken into pieces, and the fourth jack was not broken, therefore it remains as piece.