Implement the persistent stack.
The first line contains the number of operations (1 \le n \le 200\,000). The line i + 1 describes the operation :
— add to the top of stack number (0 \le t < i) the number (0 < m \le 1000);
— remove the top element from stack number (0 \le t < i). It is guaranteed that stack is not empty.
The result of operation , described in line i + 1, is the creation of stack number . Initially, there is an empty stack with number zero.
All input numbers are integers.
For each delete operation, print the deleted element in a separate line.
Example 1