#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 SS and FF , such that there exist three routes between them. Moreover, each city except SS and FF 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 SS , drives along one of those routes and tries to get to city FF 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 TT -- number of countries (1T100000)(1 \le T \le 100 000) . It is followed by TT country descriptions.

The first line of each country description contains two integers nn and mm -- the number of its cities and roads (1n,m100000)(1 \le n , m \le 100 000) . The following mm lines contain two integer numbers each: uiu_{i} and viv_{i} -- the cities at the ends of the road (1ui<vin)(1 \le u_{i} < v_{i} \le n) . 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 100000100 000 .

输出格式

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 1−1 . Otherwise the first line of the answer should contain two integers SS and FF -- start and finish cities. The next three lines should contain three distinct routes. Each route is described by an integer kk -- the number of cities it visits, and kk numbers v1,v2,,vkv_{1}, v_{2}, \cdots , v_{k} -- the cities, where v1=S,vk=Fv_{1} = S , v_{k} = F , and there is a road between cities viv_{i} and vi+1v_{i+1} for all 1ik11 \le i \le k − 1 .

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.