You are given a rooted tree consisting of n vertices. The vertices of the tree are numbered by integers from 1 to n. The parent of vertex v is represented as parv. The root of the tree is a vertex with number 1.
You are required to answer q queries. Each query is described by two integers vj and uj. The answer to query vj, uj is the minimum number of attempts for reaching the vertex uj from vj. You can perform one of the following operations per attempt:
Input format
Output format
For each query, print the minimum number of attempts to reach from the first node to the second node.
The path for each query is as follows (select path with minimum length):
7 -> 5 -> 1
7 -> 3 -> 8
5 -> 1 -> 10
9 -> 3 -> 4 -> 5 -> 6