{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n Farmer John\u0027s cows refused to run in his marathon since he chose a path much too long for their leisurely lifestyle. He therefore wants to find a path of a more reasonable length. The input to this problem consists of the same input as in \"Navigation Nightmare\",followed by a line containing a single integer K, followed by K \"distance queries\". Each distance query is a line of input containing two integers, giving the numbers of two farms between which FJ is interested in computing distance (measured in the length of the roads along the path between the two farms). Please answer FJ\u0027s distance queries as quickly as possible! \n \u003cbr\u003e\n \u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n * Lines 1..1+M: Same format as \"Navigation Nightmare\" \n \u003cbr\u003e \n \u003cbr\u003e* Line 2+M: A single integer, K. 1 \u0026lt;\u003d K \u0026lt;\u003d 10,000 \n \u003cbr\u003e \n \u003cbr\u003e* Lines 3+M..2+M+K: Each line corresponds to a distance query and contains the indices of two farms. \n \u003cbr\u003e\n \u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n * Lines 1..K: For each distance query, output on a single line an integer giving the appropriate distance. \n \u003cbr\u003e\n \u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e7 6\n1 6 13 E\n6 3 9 E\n3 5 7 S\n4 1 3 N\n2 4 20 W\n4 7 2 S\n3\n1 6\n1 4\n2 6\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e13\n3\n36\n\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\n \u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\n Farms 2 and 6 are 20+3+13\u003d36 apart. \n\n 输入n和m,表示n个点m条边,下面m行是边的信息,两端点和权,后面的那个字母无视掉,与本题无关,没用的。\n \u003cbr\u003e\n \u003c/div\u003e"}}]}