#P7025. [NWRRC 2017] Grand Test
[NWRRC 2017] Grand Test
题目描述
Jeremy, Richard and James like to test cars. It is always hard for them to decide where they should do it. Usually car test looks like this. They choose a country and examine its cities and two-way roads that connect them. To perform a test, they need to choose two different cities and , such that there exist three routes between them. Moreover, each city except and should be visited by at most one route, and none of the roads may be used twice.
Then each of them takes a car in city , drives along one of those routes and tries to get to city faster than others.
You are given a description of multiple countries. For each country you should decide if it is possible to choose two cities and three routes between them in a way described above.
输入格式
The first line of the input contains a single integer -- number of countries . It is followed by country descriptions.
The first line of each country description contains two integers and -- the number of its cities and roads . The following lines contain two integer numbers each: and -- the cities at the ends of the road . All roads are two-way. Each pair of cities is connected by at most one road.
Both the total number of cities and roads in all countries does not exceed .
输出格式
Output the answer for each country in the order they are given in the input.
If it is not possible to test cars in this country, the answer is . Otherwise the first line of the answer should contain two integers and -- start and finish cities. The next three lines should contain three distinct routes. Each route is described by an integer -- the number of cities it visits, and numbers -- the cities, where , and there is a road between cities and for all .
2
6 6
3 6
3 4
1 4
1 2
1 3
2 3
3 1
1 2
1 3
3 1 2 3
2 1 3
3 1 4 3
-1
提示
Time limit: 3 s, Memory limit: 512 MB.