Minimum in the Stack#207

Minimum in the Stack

3 seconds
128 megabytes
Easy (≈1000)

In the data structure, it is required to perform the following operations:

Input

The first line provides the number of operations n~(1 \le n \le 10^6). The next lines each consist of one of the following types of operations:

  • 1 x - adds the element x.

  • 2 - removes the element from the end.

  • 3 - finds the minimum element.

x\:(-10^9 \le x \le 10^9) and all operations are guaranteed to be valid.

Output

Provide the result of the 3 operation on each line.

Examples

Example 1

Loading
Loading