CyberStars

Stack Implementation

Implement a Stack class using an ArrayList as the internal storage. The stack should support push, pop, and peek operations.

Process commands from stdin and print results for pop and peek. If pop or peek is called on an empty stack, print Empty.

Input

  • Line 1: number of commands N (1 <= N <= 2·10^4)
  • For each command:
    • Line 1: command type (push, pop, or peek)
    • Only for push, line 2: the integer X (any int value)

Behavior:

  • push X: push X onto the stack
  • pop: remove and print the top element
  • peek: print the top element without removing it

Output

  • For each pop: the removed value, or Empty
  • For each peek: the top value, or Empty

Examples

Input:
6
push
10
push
20
peek
pop
pop
pop

Output:
20
20
10
Empty
Input:
3
push
5
push
15
peek

Output:
15
Input:
2
pop
peek

Output:
Empty
Empty

Both pop and peek must print Empty when the stack has nothing in it.