Problems
Implement a stack
Implement a stack
Mary just learned about a new, fashionable structure. It includes "\textbf{push}" and "\textbf{pop}" operations.
Implement a stack with two operations. The “first” operation pushes a number onto the stack, and the “second” operation removes an element from the top of the stack. For each “second” operation, print the removed number. It is guaranteed that all operations are correct.
\InputFile
The first line contains the number of operations $n~(1 \le n \le 10^5)$. In the next $n$ lines the first number is the operation number, and the second (only for the "first" operation) is the number to be added. This number is a positive integer and does not exceed $10^5$.
\OutputFile
Print all removed numbers one per line.
\includegraphics{https://static.e-olymp.com/content/dc/dc81e766898ce23bc1380b1068e7cf36897c8b0d.gif}
Input example #1
6 1 1 1 2 2 1 4 2 2
Output example #1
2 4 1
Input example #2
3 1 1 1 2 1 3
Output example #2