The company Kommunikation-Ist-Toll (KIT) has achieved world wide fame for its various messenger apps – they have already published $$$10^9$$$ of those! Obviously, this is a lot of work for the employees. Thus, KIT is always trying to recruit ICPC participants for internships.
Internally, KIT is organized in a tree structure: Employee $$$1$$$ is the CEO, and every other employee $$$i$$$ has a direct boss numbered $$$p_i$$$. Obviously, KIT uses its own messengers for company intern communication. In particular, employee $$$i$$$ uses the messenger app with id $$$x_i$$$ to communicate with the direct boss $$$p_i$$$.
When someone is doing an internship at KIT, they are assigned some direct boss as well as the messenger app used for communication with this boss. Since KIT offers great jobs$$$^{\text{∗}}$$$, all interns stay at KIT and continue working as ex-interns. Then, they can also become the direct boss of some new interns.
To get the internship at KIT, you have to solve the following interview problem about efficiently simulating the company structure:
$$$^{\text{∗}}$$$For example, you are allowed to play table football during work.
The interactor first sends one line with one integer $$$q$$$ ($$$1 \leq q \leq 2 \cdot 10^5$$$), describing the number of events which you have to simulate.
After this, you receive $$$q$$$ lines with events described as above in the following format:
Here, $$$n'$$$ represents the number of employees KIT currently employs prior to this interaction. (Initially, $$$n' = 1$$$) For each event of type 2, output and flush its answer in one line, before reading the next event.
Let $$$q_1, q_2$$$ be the number of events of type $$$1$$$ and $$$2$$$, respectively. It is guaranteed that $$$q_1, q_2 \leq 10^5$$$.
101 1 21 2 22 1 32 2 11 1 22 3 41 4 32 3 41 5 12 3 6
-1 2 2 2 3