You are given a tree consisting of
n vertices (numbered from
1 to
n). Initially all vertices are white. You have to process
q queries of two different types:
-
1 x − change the color of vertex x to black. It is guaranteed that the first query will be of this type.
-
2 x − for the vertex x, find the minimum index y such that the vertex with index y belongs to the simple path from x to some black vertex (a simple path never visits any vertex more than once).
For each query of type
2 print the answer to it.
Note that the queries are given in modified way.
Output
For each query of type
2 output the answer to it.