You are given a directed graph with vertices. The special thing about the graph is that each vertex has at most one outgoing edge. Your task is to answer the following two types of queries:
1 a - delete the only edge outgoing from vertex . It is guaranteed that the edge exists (1 \le a \le n),
2 a b - output the length of the shortest path from vertex to vertex , if the path exists. Otherwise output without quotes (1 \le a, b \le n).
First line contains a natural number (n \le 10^5) - the number of vertices in the graph. The following line contains integer numbers, -th number is next_i (0 \le next_i \le n), meaning that there is an edge from vertex to vertex next_i. If next_i = 0, assume that there is no outgoing edge from vertex . Third line contains a natural number (m \le 10^5) - the number of queries. The following contain a query each. Queries are given in the manner described above.
On the -th line output the answer for the -th query of type 2 a b.
1-nji mysal
2-nji mysal