Competitions
Stack Data Structure
Stack push / pop
Simulate the operations with the stack:
- push x - insert value x into the stack;
- pop - delete the top element;
- top - print the top element (without deleting it);
All pop commands are correct.
If stack is empty and top command arrives, print nothing.
Input
Each line contains a single command.
Output
For each top command print on a separate line the corresponding result.
Input example #1
push 5 push 2 top pop top pop top push 7 top
Output example #1
2 5 7