Simple Stack#204

Simple Stack

2 seconds
128 megabytes
Very easy (≈850)

Implement the stack data structure. Write a program that provides the description of the stack and simulates its operation by implementing all the given methods of the stack. The program reads sequential commands and performs various operations depending on the command. After executing each command, the program must output a line. The possible commands for the program are:

The input command set is guaranteed to meet the following requirements: the maximum number of elements in the stack at any time does not exceed , all pop and back commands are valid, which means there is at least one element in the stack during their execution.

Input

Explained in the problem statement. See the example of the input data.

Output

Given in the problem statement. See the example of the output data.

Examples

Example 1

Loading
Loading