Raphael has developed a new operating system. A new file can be created in it in two ways: by copying a previously created file and adding some number to it, or by copying a previously created file and deleting the last number from it. If the file being copied is empty and a delete operation is applied to it, then an empty file is created again.
At the very beginning, Raphael's operating system contains only one empty file, root. File root has number .
Raphael wants to create files one after another. The -th file can be created in one of two ways:
"push id x" — create a copy of the file with number (id < i) and add the number (0 \le x \le 10^9) to the end of the new file. Print the number of elements in the newly created file (it has number ).
"pop id" — create a copy of the file with number (id < i) and remove the last number from the new file (if it exists). Print the deleted number (or "-1" if it does not exist).
The first line contains the number (1 < n \le 3 \cdot 10^5) of created files. The following lines contain the ways to create files: the -th line describes one of the two ways to create the -th file.
Each time you create a new file, print the required result.
Example 65
Example 66