As a student of Dr. Panev Philosophy class, Ridiculous Ray will have to write an in-class essay next week.
Ridiculous Ray has not been studying however, and needs to learn the topics from scratch. Additionally, as he is very lazy, he wants you to help him find the minimum effort to become prepared.
On the test, there are
Additionally, to make the test more difficult, Dr. Panev has decided to remove one of the potential topics on the day of the test (which means that Ray cannot write about it). And as Ridiculous Ray wants to be prepared for every possible scenario, he wants you to find the smallest set of topics he can study such that no matter which topic is removed, he will still have studied a pair of related topics that he can write about (or tell him that it is impossible).
Constraints
For all subtasks:
Subtask 1 [10%]
Subtask 2 [30%]
Subtask 3 [60%]
No additional constraints.
Input Specification
The first line contains the integers
The next
Output Specification
If no set of topics exists that satisfies Ray's constraints, output only -1
on a single line.
Otherwise, let
On the first line, output the size of
On the second line, output
If multiple possibilities exist for
Sample Input 1
6 6
2 5
5 3
2 3
2 6
3 6
1 5
Sample Output 1
3
2 3 5
Sample Explanation 1
While
Sample Input 2
5 4
1 5
2 5
3 5
4 5
Sample Output 2
-1
Comments