One of Hyperskill authors discovered her passion for designing and drew the following graph-logo of JetBrains Academy:
Then she came up with the following task: find all the spanning trees of the graph above.
Output the edges of the spanning tree in one row, separated by a comma. Write each spanning tree in a new row. If no spanning tree exists, output FAIL instead.
Note: You are presented one graph with several connected components, and not three separate graphs! How do we find a spanning tree for the graphs consisting of several connected components? Is the above graph connected?
Answer example:
2 1, 5 3, 7 8
5 2, 7 2, 8 1, 6 3