It's Christmas time and Leonard has bought a small Christmas tree and placed right in the center of hall. Seeing the tree, Sheldon remembers that he has to solve a graph problem.
The problem states that given a tree graph, initially containing just one node labeled 1. There are Q queries, each one being one of following two types--
Input Format:
First line contains Q, number of queries.
Each of the next Q lines denote a query. if it starts with 1, it is of type 1 and another integer p follows. If it starts with 2, it denotes the query of type 2.
Output Format:
Output the required answer for each query of type 2.
Constraints:
1≤Q≤105
1≤p≤ max label currently in the tree
For 1st query, there is only one node. Hence, max distance is 0.
For 2nd query, we connect node labeled 2 with node labeled 1 as 2 is the least label which is not currently present in the tree.
For3rd query, we connect node labeled 3 with node labeled 2 as 3 is the least label which is not currently present in the tree.
For 4th query, max distance is between node 1 and node 3 which is 2.
For 5th query, we connect node labeled 4 with node labeled 3 as 4 is the least label which is not currently present in the tree.
For 6th query, max distance is between node 1 and node 4 which is 3.