Professor Oak is dealing with the final exams of his course. He can either:
Put an exam on top of the other exams on his desk.
Remove the exam on top.
Check which is the best qualification among the exams on his desk.
Please help him to do it efficiently.
To avoid large input files, the commands and numbers will be pseudo-randomly generated. The integer sequence will be produced by the following linear congruential generator:
A := 8433437992146984169
B := 7905438737954111703
X := S // initial seed
function nextinteger():
X := (A*X + B) mod 2^64
return X / 2^32
For each number returned, the command will be:
“Put”, if . The grade of the exam will be the next pseudo-random number generated, which should not be counted as a command.
“Remove”, if and .
“Check”, if and .
Input consists of several cases, each with the number of instructions
(between 0 and
)
and the initial seed
(between 0 and
).
Print “EMPTY DESK” every time that Prof. Oak tries to
remove an exam or check the best qualification but there are no exams on
his desk.
For every case, print the best qualification for every query, together with the error messages. Print a blank line after every case.
Input
9 3 19 18446744073709551614 1 10
Output
3931067935 EMPTY DESK 4132970100 4208990443 4208990443 EMPTY DESK