{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e \"Guanxi\" is a very important word in Chinese. It kind of means \"relationship\" or \"contact\". Guanxi can be based on friendship, but also can be built on money. So Chinese often say \"I don\u0027t have one mao (0.1 RMB) guanxi with you.\" or \"The guanxi between them is naked money guanxi.\" It is said that the Chinese society is a guanxi society, so you can see guanxi plays a very important role in many things.\u003cbr\u003e\u003cbr\u003e Here is an example. In many cities in China, the government prohibit the middle school entrance examinations in order to relief studying burden of primary school students. Because there is no clear and strict standard of entrance, someone may make their children enter good middle schools through guanxis. Boss Liu wants to send his kid to a middle school by guanxi this year. So he find out his guanxi net. Boss Liu\u0027s guanxi net consists of N people including Boss Liu and the schoolmaster. In this net, two persons who has a guanxi between them can help each other. Because Boss Liu is a big money(In Chinese English, A \"big money\" means one who has a lot of money) and has little friends, his guanxi net is a naked money guanxi net -- it means that if there is a guanxi between A and B and A helps B, A must get paid. Through his guanxi net, Boss Liu may ask A to help him, then A may ask B for help, and then B may ask C for help ...... If the request finally reaches the schoolmaster, Boss Liu\u0027s kid will be accepted by the middle school. Of course, all helpers including the schoolmaster are paid by Boss Liu.\u003cbr\u003e\u003cbr\u003e You hate Boss Liu and you want to undermine Boss Liu\u0027s plan. All you can do is to persuade ONE person in Boss Liu\u0027s guanxi net to reject any request. This person can be any one, but can\u0027t be Boss Liu or the schoolmaster. If you can\u0027t make Boss Liu fail, you want Boss Liu to spend as much money as possible. You should figure out that after you have done your best, how much at least must Boss Liu spend to get what he wants. Please note that if you do nothing, Boss Liu will definitely succeed.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":" There are several test cases.\u003cbr\u003e\u003cbr\u003e For each test case:\u003cbr\u003e\u003cbr\u003e The first line contains two integers N and M. N means that there are N people in Boss Liu\u0027s guanxi net. They are numbered from 1 to N. Boss Liu is No. 1 and the schoolmaster is No. N. M means that there are M guanxis in Boss Liu\u0027s guanxi net. (3 \u0026lt;\u003dN \u0026lt;\u003d 30, 3 \u0026lt;\u003d M \u0026lt;\u003d 1000)\u003cbr\u003e\u003cbr\u003e Then M lines follow. Each line contains three integers A, B and C, meaning that there is a guanxi between A and B, and if A asks B or B asks A for help, the helper will be paid C RMB by Boss Liu.\u003cbr\u003e\u003cbr\u003e The input ends with N \u003d 0 and M \u003d 0.\u003cbr\u003e\u003cbr\u003e It\u0027s guaranteed that Boss Liu\u0027s request can reach the schoolmaster if you do not try to undermine his plan."}},{"title":"Output","value":{"format":"HTML","content":" For each test case, output the minimum money Boss Liu has to spend after you have done your best. If Boss Liu will fail to send his kid to the middle school, print \"Inf\" instead."}},{"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 3\r\n1 3 7\r\n1 4 50\r\n2 3 4\r\n3 4 2\r\n3 2\r\n1 2 30\r\n2 3 10\r\n0 0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e50\r\nInf\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}