eolymp
bolt
Try our new interface for solving problems
Problems

Peaceful Comission

Peaceful Comission

The Public Peace Commission should be legislated in Parliament of The Democratic Republic of Byteland according to The Very Important Law. Unfortunately one of the obstacles is the fact that some deputies do not get on with some others. The Commission has to fulfill the following conditions: \begin{itemize} \item Each party has exactly one representative in the Commission, \item If two deputies do not like each other, they cannot both belong to the Commission. \end{itemize} Each party has exactly two deputies in the Parliament. All of them are numbered from \textbf{1} to \textbf{2n}. Deputies with numbers \textbf{2i-1} and \textbf{2i} belong to the \textbf{i}-th party. Write a program, which: \begin{itemize} \item reads from the standard input the number of parties and the pairs of deputies that are not on friendly terms, \item decides whether it is possible to establish the Commission, and if so, proposes the list of members, \item writes the result to the standard output. \end{itemize} \InputFile In the first line of the input file there are two non-negative integers \textbf{n} and \textbf{m}. They denote respectively: the number of parties, \textbf{1} ≤ \textbf{n} ≤ \textbf{8000}, and the number of pairs of deputies, who do not like each other, \textbf{0} ≤ \textbf{m} ≤ \textbf{20000}. In each of the following \textbf{m} lines there is written one pair of integers \textbf{a} and \textbf{b}, \textbf{1} ≤ \textbf{a} < \textbf{b} ≤ \textbf{2n}, separated by a single space. It means that the deputies \textbf{a} and \textbf{b} do not like each other. There are multiple test cases. Process to end of file. \OutputFile The output file should contain one word \textbf{NIE} (means \textbf{NO} in Polish), if the setting up of the Commission is impossible. In case when setting up of the Commission is possible the output file should contain \textbf{n} integers from the interval from \textbf{1} to \textbf{2n}, written in the ascending order, indicating numbers of deputies who can form the Commission. Each of these numbers should be written in a separate line. If the Commission can be formed in various ways, your program may write mininum number sequence.
Time limit 1 second
Memory limit 32 MiB
Input example #1
3 2
1 3
2 4
Output example #1
1
4
5
Source POI 2001