Bob and Athens are at war again. This time, Athens has sent spies in Bob to get secret information about Bob's strategies. But, this information has reached Bob. He does not know who the spies are, but know that each day, one spy will start in a village, and go to another village via a network of roads, and is the shortest path between the two villages, hiding the information in each village.
It is guaranteed that the network of roads forms a connected acyclic graph, and initially, Bob is in the village with index 1.
After the spy has done his work, Bob starts from his current location, and via the shortest path, go to the village where the spy went while destroying any hidden information he finds. That is, if Bob visits a village that the spy also visited, he will destroy the information. After reaching the village, Bob takes care of the spy, and waits in that village until the next day, for the next spy to begin his work.
Since Bob likes to self evaluate, he wants that how much information he couldn't destroy each day, and might be in hands of Athens
INPUT:
The first line of input contains a single integer N, no of Bob villages. (2 ≤ N ≤ 105)
The next N - 1 line contains two integers each Ui and Vi which represent that there is a road between two villages. (1 ≤ Ui, Vi ≤ N)
After that, it contains a single integer Q. (1 ≤ Q ≤ 105)
Next, the Q line will have 2 integers each, s and e (1 ≤ s, e ≤ N) representing starting and ending points of the spy.
OUTPUT:
For each day of Q days, output an integer, the number of information packets Bob couldn't destroy
Sample input
Sample output
7
1 2
2 3
2 4
3 5
3 6
4 7
3
7 5
1 7
2 4
2
1
1
Answers
Answered by
0
Answer:
here this your answer
Explanation:
make a brilliant
Attachments:
Similar questions