Description

請撰寫一支程式,根據以下兩種指令進行不同行為:

push n:將 n 放到stack的最上方,不須印出或回傳任何東西。

popuntilmax:從 top 開始進行pop,並依照 pop 的順序印出被 pop 掉的數字,直到最大值為止(最大值也要 pop 掉),不須回傳任何東西。如果同時有兩個或以上最大值,請只需要 pop 到比較頂端的那個最大值即可,例如:Stack上到下為 45 17 45,則只需要 pop 掉 45。

Please write a program that behaves differently based on the following two commands:

push n: Place n on top of the stack, without printing or returning anything.

popuntilmax: Begin popping from the top, and print the popped numbers in the order of popping until the maximum value is reached (the maximum value should also be popped), without returning anything.If there are two or more maximum values at the same time, just pop until reaching the one closer to the top of the stack. For example, if the stack from top to bottom is 45 17 45, only pop 45.

Input

輸入包含多行,一行一指令,直到 EOF,格式請參考 Sample Input。

The input consists of multiple lines, with one command per line, until EOF. Refer to the Sample Input for the format.

Output

只有 popuntilmax 會進行輸出,且印出的數字與數字間以空白隔開。但如果執行 popuntilmax 前 Stack 為空,則印出 "Empty Stack"。

Only popuntilmax will produce output, and the popped numbers should be separated by spaces. However, if the stack is empty before executing popuntilmax, print "Empty Stack".

Sample Input 1

push 10
push 5
popuntilmax
push 21
push 74
push 50
push 13
popuntilmax
push 9
popuntilmax
popuntilmax
popuntilmax
push 15

Sample Output 1

5 10
13 50 74
9 21
Empty Stack
Empty Stack