#Q99. 「一本通 3.5 练习 5」和平委员会
「一本通 3.5 练习 5」和平委员会
Description
Original source: POI 2001
According to the constitution, the Public Peace Committee of the Byteland Democratic Republic should be established through legislative procedures in Congress. Unfortunately, due to discord among certain party representatives, there are obstacles to this matter.
The committee must satisfy the following conditions:
-
Each party has exactly representative in the committee,
-
If two representatives dislike each other, they cannot both belong to the committee.
Each party has representatives in the parliament. Representatives are numbered from to . Representatives numbered and belong to the -th party.
Task: Write a program that reads the number of parties and pairs of representatives who are unfriendly, determines whether it is possible to establish the Peace Committee, and if so, lists the members of the committee.
Input Format
The first line contains two non-negative integers and . They represent the number of parties and the number of unfriendly representative pairs . The next lines each contain a pair of integers , indicating that representatives and dislike each other.
Output Format
If the committee cannot be established, output the message NIE. If it can be formed, output integers selected from the range to , one per line, in ascending order. These numbers represent the IDs of the representatives in the committee.
If the committee can be formed in multiple ways, the program may output any one of them.
Sample 1
3 2
1 3
2 4
1
4
5
Constraints & Hints
$1 \le n \le 8000,0 \le m \le 20000,1 \le a < b \le 2n$