Welcome to the world of Pokermon, yellow little mouse-like creatures, who absolutely love playing poker!
Yeah, right…
In the ensuing Pokermon League, there are
Your task is to divide players into teams and the teams into two conferences, so that:
- each trainer belongs to exactly one team
- no team is in both conferences
- total hate between conferences is at least
- every trainer is in a team from his wish list
Total hate between conferences is calculated as the number of pairs of trainers from teams from different conferences who hate each other.
Input Specification
The first line of input contains
- total number of Pokermon trainers - number of pairs of trainers who hate each other
Each Pokermon trainer is represented by a number between
The next
The next
Starting with Pokermon trainer
- first number
- a size of Pokermon trainers wish list - in the next line are positive integers
- the teams Pokermon trainer would like to be on.
Each trainer's wish list will not contain repeating teams.
Teams on the wish lists are numbered in such a way that the set of all teams that appear on at least
Output Specification
Contains 2 lines:
- The first line contains
numbers, specifying the team every trainer is in. First for trainer , then , etc. - The second line contains
numbers where for every team, starting with team , there is an integer specifying the conference ( or ) of that team.
Constraints
Sample Input
4 3
1 2
2 3
4 1
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 15
16
2 3 4 5 6 7 8 9 10 11 12 13 14 15 17 18
16
2 3 4 5 6 7 8 9 10 11 12 13 14 15 18 19
16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 16 19
Sample Output
1 2 2 3
1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
Explanation
Conference
Pokermon trainer
Comments