{"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 m. 2 \u0026lt;\u003d n,m \u0026lt;\u003d 40,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输入部分解释:\nLine 1: Two space-separated integers: N and M\n\n\n\n* Lines 2..M+1: Each line contains four space-separated entities, F1,\n\n F2, L, and D that describe a road. F1 and F2 are numbers of\n\n two farms connected by a road, L is its length, and D is a\n\n character that is either \u0027N\u0027, \u0027E\u0027, \u0027S\u0027, or \u0027W\u0027 giving the\n\n direction of the road from F1 to F2.\n\n\n\n* Line M+2: A single integer, K (1 \u003c\u003d K \u003c\u003d 10,000), the number of FB\u0027s\n\n queries\n求询问的两点间距离\n \u003cbr\u003e\n \u003c/div\u003e"}}]}