Implement a persistent priority queue.
The first line contains the number of operations, (1 \le n \le 200000). Each of the following lines describes an operation :
- Add the number (0 < m \le 100000) to the structure identified by number (0 \le x < i).
- Remove the maximum element from the structure identified by number (0 \le x < i). It is guaranteed that the priority queue is not empty.
Each operation , described on line i + 1, results in the creation of a new structure numbered . Initially, there is an empty structure numbered zero.
For each removal operation, output the removed element on a separate line.
Example 1