АВТ
Language: Russian
English

Remote Training on Programming

Problems Online status Contests
News FAQ E-learning
For authors:
Register  ||  Login
 
Hello, Guest! Please login or register.

1584. Interesting Places

Time Limit: 1 seconds
Memory Limit:262144KB
Points:100
View Problem Statistics Submit Problem added debug

The H&H CTO Mr.H. is a very busy and suspicious person. As he is very busy he visits a lot of different places during the day. And as he is suspicious he uses only well-known for him roads between this places. Recently the traffic load on the streets became pretty high. So Mr.H. would like to make sure, that there are at least two different routes he can safely drive between every two places of his interest. Two routes are considered different if they have no common roads (but can have common intermediate places). All roads are bidirectional.

You are given the list of Mr.H.'s places of interest and list of currently safe roads. Your task is to find minimal number of roads to be added to satisfy Mr.H.'s requirements.

Входные данные

The first line of the input file contains two integer numbers: the number of places of interest N (1 ≤ N ≤ 900) and the number of safe roads M (1 ≤ M ≤ 100000). Each of the following M lines contains the description of the corresponding road — the number of places it connects. There is not more then one road between every two places.

Выходные данные

Write in the first line of the output file number of additional roads Q. Write in the following Q lines descriptions of additional vertices — numbers of places the corresponding road connects in any order separated by a space. If there is no solutions, output single integer "-1". After adding new roads every two places should remain connected with not more then one road.

Пример

Входные данные
4 3
1 2
2 3
3 4
Выходные данные
1
4 1


View Problem Statistics Submit Problem discussion Author/source:
Problems from Contests and Camps / Trainings in Perm 2009 / 07.07.09 Big Contest /
1583. B - Square Root 1584. 1585. D - Road to Home 1586. E - Ant and Apples 1587. F - Square
time generating 0.156 sec.
© Copyright VSU, AVT, Nosov D.A., Andrianov I.A.