The input contains several test cases. The first line of each test case contains two integersThe following
lines each contains three integers
, which means there is an edge between node
and
of length
. The last test case is followed by two zeros.
For each test case output the answer on a single line.