АВТ
Язык:

Дистанционный практикум по программированию

Задачи Online статус Соревнования
Новости Справка СДО
 
Здравствуйте, Гость! Войдите с паролем или зарегистрируйтесь.

1584. Interesting Places

Ограничение времени: 1 сек.
Ограничение памяти:262144 КБайт
Баллы:100
Статистика Послать на проверку Задачу добавил 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


Статистика Послать на проверку Обсуждение задачи Автор/источник:
Задачи с соревнований и сборов / Сборы в Перми 2009 / 07.07.09 Большой контест /
1583. B - Square Root 1584. 1585. D - Road to Home 1586. E - Ant and Apples 1587. F - Square
 
время генерации 0.61 сек.
© Copyright ВоГУ, АВТ, Носов Д.А., Андрианов И.А.