{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eOne cow from each of \u003ci\u003eN\u003c/i\u003e farms (1 ≤ \u003ci\u003eN\u003c/i\u003e ≤ 1000) conveniently numbered 1..\u003ci\u003eN\u003c/i\u003e is going to attend the big cow party to be held at farm #\u003ci\u003eX\u003c/i\u003e (1 ≤ \u003ci\u003eX\u003c/i\u003e ≤ \u003ci\u003eN\u003c/i\u003e). A total of \u003ci\u003eM\u003c/i\u003e (1 ≤ \u003ci\u003eM\u003c/i\u003e ≤ 100,000) unidirectional (one-way roads connects pairs of farms; road \u003ci\u003ei\u003c/i\u003e requires \u003ci\u003eT\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e (1 ≤ \u003ci\u003eT\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e ≤ 100) units of time to traverse.\u003c/p\u003e\u003cp\u003eEach cow must walk to the party and, when the party is over, return to her farm. Each cow is lazy and thus picks an optimal route with the shortest time. A cow\u0027s return route might be different from her original route to the party since roads are one-way.\u003c/p\u003e\u003cp\u003eOf all the cows, what is the longest amount of time a cow must spend walking to the party and back?\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"Line 1: Three space-separated integers, respectively: \u003ci\u003eN\u003c/i\u003e, \u003ci\u003eM\u003c/i\u003e, and \u003ci\u003eX\u003c/i\u003e\r\u003cbr\u003eLines 2..\u003ci\u003eM\u003c/i\u003e+1: Line \u003ci\u003ei\u003c/i\u003e+1 describes road \u003ci\u003ei\u003c/i\u003e with three space-separated integers: \u003ci\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, \u003ci\u003eB\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, and \u003ci\u003eT\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e. The described road runs from farm \u003ci\u003eA\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e to farm \u003ci\u003eB\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, requiring \u003ci\u003eT\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e time units to traverse."}},{"title":"Output","value":{"format":"HTML","content":"Line 1: One integer: the maximum of time any one cow must walk."}},{"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\u003e4 8 2\r\n1 2 4\r\n1 3 2\r\n1 4 7\r\n2 1 1\r\n2 3 5\r\n3 1 2\r\n3 4 4\r\n4 2 3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e10\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"Cow 4 proceeds directly to the party (3 units) and returns via farms 1 and 3 (7 units), for a total of 10 time units."}}]}