Tao Yuanming(365-427) was a Chinese poet of Eastern Jin dy- nasty. One of his most famous works is ”Peach Blossom Spring”, which is a fable about a chance discovery of an ethereal village where the people lead an ideal existence in harmony with nature, unaware of the outside world for centuries. So in Chinese, ”Peach Blossom Spring” means ”utopia”. In the story of ”Peach Blossom Spring”, there was a myste- rious place. In Qin dynasty, some people escaped to that place during the civil unrest and built a village. They and their de- scendants never left and never had any contact with the outside world since then, until centuries latter a fisherman of Jin dynasty found them. Recently, some Chinese ACMers happened to find the relics of the village mentioned in”Peach Blossom Spring”. They also found a document about building hiding places to escape from Qin army. The document said: There were n houses and m roads in the village. Each road connected two houses. These houses were numbered from 1 to n. There were k families, each living in a different house. The houses they lived were house1, house2, . . . , housek. There were also k housen−k+1, housen−k+2, . . . , housen, with secret basements so that those houses could be used as hid- ing places. The problem was that all roads were broken. People wanted to repair some roads so that every family could reach a hiding place through the repaired roads. Every hiding place could only hold one family. Each road cost some labor to be repaired. The head of the village wanted to find out the minimum cost way of repairing the roads, but he didn’t know how to do. Would you solve the problem which the ancient village head never solved? Input The input begins with a line containing an integer T (T ≤ 50), the number of test cases. For each case, the first line begins with three integers — the above mentioned n (4 ≤ n ≤ 50), m (0 ≤ m ≤ 1000) and k (1 ≤ k ≤ 5, 2k ≤ n). Then m lines follow, each containing three integers u,v and w, indicating that there is a broken road connecting house u and v, and the cost to repair that road is w (1 ≤ w ≤ 1000). Output For each test case, if you cannot find a proper way to repair the roads, output a string ‘No solution’ in a line. Otherwise, output the minimum cost to repair the roads in a line. Sample Input 2 431 4 2 10 319 broken houses:
2/2 2 3 10 672 1 5 1000 2 6 1000 131 231 341 451 461 Sample Output 29 5