{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"When FJ\u0027s friends visit him on the farm, he likes to show them around. His farm comprises N (1 \u0026lt;\u003d N \u0026lt;\u003d 1000) fields numbered 1..N, the first of which contains his house and the Nth of which contains the big barn. A total M (1 \u0026lt;\u003d M \u0026lt;\u003d 10000) paths that connect the fields in various ways. Each path connects two different fields and has a nonzero length smaller than 35,000.\r\u003cbr\u003e\r\u003cbr\u003eTo show off his farm in the best way, he walks a tour that starts at his house, potentially travels through some fields, and ends at the barn. Later, he returns (potentially through some fields) back to his house again.\r\u003cbr\u003e\r\u003cbr\u003eHe wants his tour to be as short as possible, however he doesn\u0027t want to walk on any given path more than once. Calculate the shortest tour possible. FJ is sure that some tour exists for any given farm."}},{"title":"Input","value":{"format":"HTML","content":"* Line 1: Two space-separated integers: N and M.\r\u003cbr\u003e\r\u003cbr\u003e* Lines 2..M+1: Three space-separated integers that define a path: The starting field, the end field, and the path\u0027s length.\r\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"A single line containing the length of the shortest tour.\r\u003cbr\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\u003e4 5\r\n1 2 1\r\n2 3 1\r\n3 4 1\r\n1 3 2\r\n2 4 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}