Gats and the Milk Trail
Along a corridor there are bowls, indexed from to . Bowl currently contains drops of milk.
Two kinds of events happen. Griffithm may pour milk into one bowl, or Gats may choose a segment from bowl to bowl and a thirst value .
During one drinking event, Gats examines bowls in increasing order. Empty bowls are ignored. If he reaches a bowl containing drops and still needs drops to reach his thirst value , he drinks drops from that bowl. Every drop he drinks is removed from its bowl. If he has drunk drops, or if there are no more bowls in the chosen segment, the event ends.
For every drinking event, report the number of drops Gats actually drinks.
Input
The first line contains two integers and (), the number of bowls and operations.
Output
For each operation whose first token is D, in the order those operations appear, print one line containing one integer: the number of drops Gats actually drinks during that operation. If this number is , print . If there are no operations whose first token is D, print no output.
Samples
Sample 1
Input
5 7 3 0 4 2 1 D 2 4 5 P 2 3 D 1 2 4 D 2 5 10 P 5 2 D 4 5 3 D 5 5 1
Output
5 4 4 2 0
Initially the bowls contain . The first drinking event is on bowls through with ; Gats skips bowl , drinks drops from bowl , and drinks drop from bowl . After all operations are applied in order, the printed amounts are , , , , and .