#P8076. [COCI 2009/2010 #7] RESTORAN
[COCI 2009/2010 #7] RESTORAN
Problem Description
You are given an undirected graph with nodes and edges.
Now you may color these edges red or blue. Find a coloring such that every node whose degree is at least is incident to edges of both colors. If there is no solution, output .
Input Format
The first line contains two integers .
The next lines each contain two integers , meaning the -th edge connects nodes and . The testdata guarantees that there are no multiple edges.
Output Format
If there is no solution, output .
Otherwise, output lines. Each line gives the color of an edge (in the same order as the input). Use for red and for blue.
If multiple solutions exist, output any one of them.
5 6
1 2
2 3
3 1
3 4
1 4
4 5
1
2
1
2
2
1
7 7
1 2
2 3
3 1
4 5
5 6
6 7
7 4
0
77777 4
1 2
1 3
1 4
1 5
1
2
2
2
Hint
Constraints
This problem uses bundled testdata.
- Subtask 1 (78 pts): , .
- Subtask 2 (52 pts): no additional constraints.
For of the testdata, .
Hints and Notes
You are welcome to hack the self-written Special Judge by private message or by making a post.
Translated from COCI 2009-2010 CONTEST #7 Task 6 RESTORAN.
The score settings follow the original COCI problem, with a full score of .
Translated by ChatGPT 5