{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv\u003e\u003cp\u003eFarmer John wants the cows to prepare for the county jumping competition, so Bessie and the gang are practicing jumping over hurdles. They are getting tired, though, so they want to be able to use as little energy as possible to jump over the hurdles.\u003c/p\u003e\u003cp\u003eObviously, it is not very difficult for a cow to jump over several very short hurdles, but one tall hurdle can be very stressful. Thus, the cows are only concerned about the height of the tallest hurdle they have to jump over.\u003c/p\u003e\u003cp\u003eThe cows\u0027 practice room has \u003ci\u003eN\u003c/i\u003e (1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 300) stations, conveniently labeled 1..\u003ci\u003eN\u003c/i\u003e. A set of \u003ci\u003eM\u003c/i\u003e (1 ≤ \u003ci\u003eM\u003c/i\u003e ≤ 25,000) one-way paths connects pairs of stations; the paths are also conveniently labeled 1..\u003ci\u003eM\u003c/i\u003e. Path \u003ci\u003ei\u003c/i\u003e travels from station \u003ci\u003eS\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e to station \u003ci\u003eE\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e and contains exactly one hurdle of height \u003ci\u003eH\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e (1 ≤ \u003ci\u003eH\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ 1,000,000). Cows must jump hurdles in any path they traverse.\u003c/p\u003e\u003cp\u003eThe cows have \u003ci\u003eT\u003c/i\u003e (1 ≤ \u003ci\u003eT\u003c/i\u003e ≤ 40,000) tasks to complete. Task \u003ci\u003ei\u003c/i\u003e comprises two distinct numbers, \u003ci\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e and \u003ci\u003eB\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e (1 ≤ \u003ci\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e; 1 ≤ \u003ci\u003eB\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e), which connote that a cow has to travel from station \u003ci\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e to station \u003ci\u003eB\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e (by traversing over one or more paths over some route). The cows want to take a path the minimizes the height of the tallest hurdle they jump over when traveling from \u003ci\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e to \u003ci\u003eB\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e . Your job is to write a program that determines the path whose tallest hurdle is smallest and report that height.\u003cbr\u003e \u003c/p\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e* Line 1: Three space-separated integers: \u003ci\u003eN\u003c/i\u003e, \u003ci\u003eM\u003c/i\u003e, and \u003ci\u003eT\u003c/i\u003e\u003cbr\u003e* Lines 2..\u003ci\u003eM\u003c/i\u003e+1: Line \u003ci\u003ei\u003c/i\u003e+1 contains three space-separated integers: \u003ci\u003eS\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e , \u003ci\u003eE\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e , and \u003ci\u003eH\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e \u003cbr\u003e* Lines \u003ci\u003eM\u003c/i\u003e+2..\u003ci\u003eM\u003c/i\u003e+\u003ci\u003eT\u003c/i\u003e+1: Line \u003ci\u003ei\u003c/i\u003e+\u003ci\u003eM\u003c/i\u003e+1 contains two space-separated integers that describe task i: \u003ci\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e and \u003ci\u003eB\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e \u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e* Lines 1..\u003ci\u003eT\u003c/i\u003e: Line \u003ci\u003ei\u003c/i\u003e contains the result for task\u003ci\u003e i\u003c/i\u003e and tells the smallest possible maximum height necessary to travel between the stations. Output -1 if it is impossible to travel between the two stations.\u003c/p\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 6 3\r\n1 2 12\r\n3 2 8\r\n1 3 5\r\n2 5 3\r\n3 4 4\r\n2 4 8\r\n3 4\r\n1 2\r\n5 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n8\r\n-1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}