Time limit: 0.3s
Memory limit: 2MB
Input:
Output:
Task
You are given an empty stack, an integer and operations of 4 types:
- : add to the top of the stack;
- : remove the last element from the stack;
- : print the last element of the stack;
- : print
YES
if the stack is empty, andNO
otherwise.
Input data
The first line contains the integer , and the next lines contain one operation each.
Output data
For each operation of type or , output the answer on separate lines.
Constraints and clarifications
- It is guaranteed that the operations of type and will not be performed on an empty stack.
- For the operations of type , .
Example
stdin
8
1 3
1 5
3
2
3
4
2
4
stdout
5
3
NO
YES
Explanation
The stack after each operation: