C. Nikita and stack
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Nikita has a stack. A stack in this problem is a data structure that supports two operations. Operationpush(x) puts an integerx on the top of the stack, and operation pop() deletes the top integer from the stack, i. e. the last added. If the stack is empty, then the operationpop() does nothing.
Nikita made m operations with the stack but forgot them. Now Nikita wants to remember them. He remembers them one by one, on thei-th step he remembers an operation he madepi-th. In other words, he remembers the operations in order of some permutationp1, p2, ..., pm. After each step Nikita wants to know what is the intege