
| Contests | Virtual Contests | Problems | Submit | Runs Status | Rank List | Forum |

In Figure (a), V1 indicates the source of water. Other N-1 nodes in the Figure indicate the farms we need to irrigate. An edge represents you can build a channel between the two nodes, to irrigate the target. The integers indicate the cost of a channel between two nodes.
Figure (b) represents a design of channels with minimum cost.
There are multiple cases, the first line of each case contains two integers N and M (2 ≤ N ≤ 100; 1 ≤ M ≤ 10000), N shows the number of nodes. The following M lines, each line contains three integers i j cij, means we can build a channel from node Vi to node Vj, which cost cij. (1 ≤ i, j ≤ N; i ≠ j; 1 ≤ cij ≤ 100)
The source of water is always V1.
The input is terminated by N = M = 0.
For each case, output a single line contains an integer represents the minimum cost.
If no design can irrigate all the farms, output "impossible" instead.
5 8 1 2 3 1 3 5 2 4 2 3 1 5 3 2 5 3 4 4 3 5 7 5 4 3 3 3 1 2 3 1 3 5 3 2 1 0 0
17 6
Problem setter: Hill