题目描述
Farmer John's cows refused to run in his marathon since he chose apath much too long for their leisurely lifestyle. He therefore wants to find apath of a more reasonable length. The input to this problem consists of thesame input as in "Navigation Nightmare",followed by a line containinga single integer K, followed by K "distance queries". Each distancequery is a line of input containing two integers, giving the numbers of twofarms between which FJ is interested in computing distance (measured in thelength of the roads along the path between the two farms). Please answer FJ'sdistance queries as quickly as possible!
输入
* Lines 1..1+M: Same format as "Navigation Nightmare" *Line 2+M: A single integer, K. 1 <= K <= 10,000 * Lines