問題
Each of Farmer John's
There exist
Given this information, determine an assignment of cows to favorite colors such that the number of distinct favorite colors among all cows is maximized. As there are multiple assignments that satisfy this property, output the lexicographically smallest one (meaning that you should take the assignment that minimizes the colors assigned to cows
SCORING:
Test cases 2-3 satisfy
N,M\le 10^3 .Test cases 4-10 satisfy no additional constraints.
Problem credits: William Lin and Benjamin Qi
入力
The first line contains
The next
出力
For each
例題
9 12
1 2
4 2
5 8
4 6
6 9
2 9
8 7
8 3
7 1
9 4
3 5
3 4
1
2
3
1
1
2
3
2
3
In the image below, the circles with bolded borders represent the cows with favorite color 1.
