Consider that D(G,u,v) is defined as the number of edges on the shortest path from u to v in a graph G.
You are given a tree T with N vertices and Q queries of the following type:
Note: The queries are independent in nature.
Input format
Output format
Print Q lines where the ith line contains the answer for the ith query in the chronological order.
Additional information
Above is attached tree T. The modified tree in the first query will be:
The shortest path between 4 and 6 becomes 2 compared to initial value 4. Same holds for shortest path between and 8 and 6 .