#D1837. Stack
Stack
Stack
Stack is a container of elements that are inserted and deleted according to LIFO (Last In First Out).
For stack (), perform a sequence of the following operations.
- push(, ): Insert an integer to .
- top(): Report the value which should be deleted next from . If is empty, do nothing.
- pop(): Delete an element from . If is empty, do nothing.
In the initial state, all stacks are empty.
Constraints
Input
The input is given in the following format.
:
Each query is given by
0
or
1
or
2
where the first digits 0, 1 and 2 represent push, top and pop operations respectively.
Output
For each top operation, print an integer in a line.
Example
Input
3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0
Output
3 5 2
inputFormat
Input
The input is given in the following format.
:
Each query is given by
0
or
1
or
2
where the first digits 0, 1 and 2 represent push, top and pop operations respectively.
outputFormat
Output
For each top operation, print an integer in a line.
Example
Input
3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0
Output
3 5 2
样例
3 9
0 0 1
0 0 2
0 0 3
0 2 4
0 2 5
1 0
1 2
2 0
1 0
3
5
2
</p>