Caporegime
View as PDFAfter a seemingly endless mob war, many of the caporegimes in your family are killed. Each capo leads a crew of soldiers, but now that these capos are dead, their soldiers are out of control. As the consigliere of your family, it is your job to hire new capos to lead the riotous soldiers. The soldiers you're dealing with are not gentle people. Soldiers often hold grudges with each other. As a result, certain soldiers cannot be placed in the same crew.
There are  soldiers that are out of control, and 
 two-way grudges
that you know exist between pairs of soldiers. Since the capos you're
hiring are new, you don't know if they can be trusted. The more capos
you hire, the more likely it is that one of them will rat. You must help
the Don determine the minimum number of capos required to lead the
soldiers, such that no grudges exist amongst the same crew.
Additionally, you must find one such way of grouping the soldiers.
Input Specification
The first line of input will contain two integers:  
,
the number of soldiers, and 
 
, the
number of grudges.
The next  lines will each contain two integers 
 and 
, denoting a grudge between soldiers 
 and 
.
Output Specification
The first line of output should contain an integer, the minimum number
of crews required to group the soldiers.
Each remaining line represents a separate crew. For every crew, you must
output the soldiers that it contains. You may output the groups/soldiers
in any order.
Sample Input
5 7
1 2
1 5
2 4
2 5
3 4
3 5
4 5
Sample Output
3
1 4
2 3
5
Explanation
Soldiers  and 
 are led by a capo, soldiers 
 and 
 are led by a capo,
and soldier 
 is led by another capo. There exist no grudges within any
of the three groups.
Comments