Tartarus is where the souls of the wicked go after death to be tormented for eternity. Among the unfortunate beings were the Danaïdes, daughters of Danaus. These unfortunate women are condemned to fill a barrel with pitchers of water until the end of time. Not only are their pitchers perforated, but the barrel they are trying to fill is as well.
It is the middle of summer and as Persephone roams above the Earth, Hades gets more and more irritable with each passing day. When taking some time off from managing the dead, Hades has decided to amuse himself by monitoring the punishment of the
All of the events which occur in the punishment will take one of the following
F p
The Danaïde sister completely fills her jug with water.D p
The Danaïde sister has her jug entirely drained of water.R q
The states of all of the pitchers are reverted to what they were immediately after the operation was performed, undoing all of their hard work.X
The states of all pitchers are inverted (empty becomes full and vice-versa).
The pitchers of all of the Danaïdes are initially empty.
After watching
Can you write a program to help Hades?
Input Specification
The first line of input will contain three space-separated integers
The next
Constraints
D
, F
, R
, X
Subtask 1 [20%]
Subtask 2 [80%]
Output Specification
After every operation, output two space separated integers on a single line:
The number of pitchers which are currently filled, and the maximum number of pitchers filled after the current operation takes place within the
Note: Even though the states of the pitchers may be reverted to an earlier command, the order of the operations (and thus the last
Sample Input 1
5 9 2
F 1
F 5
F 2
D 5
F 1
D 1
R 2
R 0
F 3
Sample Output 1
1 1
2 2
3 3
2 3
2 2
1 2
2 2
0 2
1 1
Explanation 1
The F 1
:
The
The number of pitchers filled after the operation F 2
would be considered the
The R 0
:
The states of the pitchers are reverted to being all empty. This is because the "
The R 2
, and R 0
commands. Note the final ordering of the commands is unaffected by the reversion of the state of the pitchers.
Sample Input 2
10 7 3
F 1
X
D 1
D 9
R 2
D 3
R 4
Sample Output 2
1 1
9 9
9 9
8 9
9 9
8 9
8 9
Comments
For some reason, the real constraint on
is 
...
why tf is memory so low
Is it possible to revert "forwards" after reverting backwards?
Something like
This would result in something like
Rip XD....Hopefully not....