#P5782. [POI 2001] 和平委员会

[POI 2001] 和平委员会

Problem Description

According to the constitution, the Public Peace Committee of the Democratic Republic of Byteland should be established by a legislative procedure in the parliament. Unfortunately, conflicts between representatives of some parties make this difficult. The committee must satisfy the following conditions:

  • Each party has exactly 11 representative in the committee.
  • If two representatives hate each other, then they cannot both be in the committee.

Each party has 22 representatives in the parliament. The representatives are numbered from 11 to 2n2n. Representatives numbered 2i12i-1 and 2i2i belong to the ii-th party.

Task: Write a program that reads the number of parties and the pairs of representatives who are unfriendly to each other, determines whether it is possible to establish the Peace Committee, and if so, outputs the list of its members.

Input Format

The first line contains two non-negative integers n,mn, m. They represent the number of parties nn and the number of unfriendly representative pairs mm, respectively.

The next mm lines each contain a pair of integers a,ba, b, meaning that representatives aa and bb hate each other.

Output Format

If it is impossible to establish the committee, output NIE.

If it is possible, output nn integers chosen from the range 11 to 2n2n, in increasing order, one per line. These numbers are the IDs of the representatives in the committee.

If the committee can be formed in multiple ways, your program may output any one of them.

3 2
1 3
2 4

1
4
5

Hint

For 42%42\% of the testdata, 1n1001 \leq n \leq 100.

For 70%70\% of the testdata, 1n10001 \leq n \leq 1000.

For 100%100\% of the testdata, 1n80001 \leq n \leq 8000, 0m200000 \leq m \leq 20000, 1a<b80001 \leq a < b \leq 8000.

Translated by ChatGPT 5