Simulate a LIFO stack of integers.
- Line 1: integer
N— the number of operations. - Next
Nlines: each is eitherpush X— push integerXonto the stack, orpop— remove and report the value on top of the stack.
For each pop operation, print the value removed from the top of the stack on
its own line. If the stack is empty when pop is issued, print -1.
Input:
5
push 3
push 7
pop
pop
pop
Output:
7
3
-1