Tree and Queries 16
Time limit8sMemory limit512 MB
Edges are added to a forest online, and each type 2 query takes a vertex u and an integer k, but the statement never defines the query answer.
Problem
There is a forest of vertices. The vertices are numbered from 1 to . The initial forest has no edges.
Input
The first line contains two integers and . (, )
Each of the next lines contains three integers , , . (, )
Consider an extra variable , which starts at 0.
- If , the arguments are and .
- If , the arguments are and . After computing the answer to this query, set to that answer.
Output
For each query with , print the answer on its own line.