{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"In the age of television, not many people attend theater performances. Antique \nComedians of Malidinesia are aware of this fact. They want to propagate theater \nand, most of all, Antique Comedies. They have printed invitation cards with all \nthe necessary information and with the programme. A lot of students were hired \nto distribute these invitations among the people. Each student volunteer has assigned \nexactly one bus stop and he or she stays there the whole day and gives invitation \nto people travelling by bus. A special course was taken where students learned \nhow to influence people and what is the difference between influencing and robbery. \n\u003cp\u003eThe transport system is very special: all lines are unidirectional and connect \n exactly two stops. Buses leave the originating stop with passangers each half \n an hour. After reaching the destination stop they return empty to the originating \n stop, where they wait until the next full half an hour, e.g. X:00 or X:30, where \n \u0027X\u0027 denotes the hour. The fee for transport between two stops is given by special \n tables and is payable on the spot. The lines are planned in such a way, that \n each round trip (i.e. a journey starting and finishing at the same stop) passes \n through a Central Checkpoint Stop (CCS) where each passenger has to pass a thorough \n check including body scan. \u003c/p\u003e\n\u003cp\u003eAll the ACM student members leave the CCS each morning. Each volunteer is to \n move to one predetermined stop to invite passengers. There are as many volunteers \n as stops. At the end of the day, all students travel back to CCS. You are to \n write a computer program that helps ACM to minimize the amount of money to pay \n every day for the transport of their employees. \u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eInput\u003c/b\u003e\u003cbr\u003e\n \u003cbr\u003e\n The input consists of N cases. The first line of the input contains only positive \n integer N. Then follow the cases. Each case begins with a line containing exactly \n two integers P and Q, 1 \u0026lt;\u003d P,Q \u0026lt;\u003d 1000000. P is the number of stops including \n CCS and Q the number of bus lines. Then there are Q lines, each describing one \n bus line. Each of the lines contains exactly three numbers - the originating \n stop, the destination stop and the price. The CCS is designated by number 1. \n Prices are positive integers the sum of which is smaller than 1000000000. You \n can also assume it is always possible to get from any stop to any other stop. \n\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eOutput\u003c/b\u003e\u003cbr\u003e\n \u003cbr\u003e\n For each case, print one line containing the minimum amount of money to be paid \n each day by ACM for the travel costs of its volunteers. \u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Input\u003c/b\u003e\u003cbr\u003e\n \u003cbr\u003e\n 2\u003cbr\u003e\n 2 2\u003cbr\u003e\n 1 2 13\u003cbr\u003e\n 2 1 33\u003cbr\u003e\n 4 6\u003cbr\u003e\n 1 2 10\u003cbr\u003e\n 2 1 60\u003cbr\u003e\n 1 3 20\u003cbr\u003e\n 3 4 10\u003cbr\u003e\n 2 4 5\u003cbr\u003e\n 4 1 50\u003c/p\u003e\n\u003cp\u003e\u003cbr\u003e\n \u003cb\u003eSample Output\u003c/b\u003e\u003cbr\u003e\n \u003cbr\u003e\n 46\u003cbr\u003e\n 210\u003cbr\u003e\n\u003c/p\u003e\n"}}]}