stack

Time limit: 0.3s
Memory limit: 2MB
Input:
Output:

Task

You are given an empty stack, an integer TT and TT operations of 4 types:

  • 1 x1 \ x: add xx to the top of the stack;
  • 22: remove the last element from the stack;
  • 33: print the last element of the stack;
  • 44: print YES if the stack is empty, and NO otherwise.

Input data

The first line contains the integer TT, and the next TT lines contain one operation each.

Output data

For each operation of type 33 or 44, output the answer on separate lines.

Constraints and clarifications

  • 1≤T≤1051 \leq T \leq 10 ^ 5
  • It is guaranteed that the operations of type 22 and 33 will not be performed on an empty stack.
  • For the operations of type 11, 1≤x≤1071 \leq x \leq 10 ^ 7.

Example

stdin

8
1 3
1 5
3
2
3
4
2
4

stdout

5
3
NO
YES

Explanation

The stack after each operation:

  1. [3][3]
  2. [3,5][3, 5]
  3. [3,5][3, 5]
  4. [3][3]
  5. [3][3]
  6. [3][3]
  7. [][]
  8. [][]

Problem info

ID: 2001

Editor: trraian

Tags:

Log in or sign up to be able to send submissions!