Problem H
Minimum Spanning Tree
Input
The input consists of several test cases. Each test case
starts with a line with two non-negative integers,
Input will be terminated by a line containing 0 0, this line should not be processed.
Output
For every test case, if there is no minimum spanning tree,
then output the word Impossible on a
line of its own. If there is a minimum spanning tree, then you
first output a single line with the cost of a minimum spanning
tree. On the following lines you output the edges of a minimum
spanning tree. Each edge is represented on a separate line as a
pair of numbers,
If there is more than one minimum spanning tree for a given graph, then any one of them will do.
Sample Input 1 | Sample Output 1 |
---|---|
4 4 0 1 1 1 2 2 1 3 3 2 3 0 2 1 0 1 100 3 0 0 0 |
3 0 1 1 2 2 3 100 0 1 Impossible |