This page is still under construction.

Parts of this page are still being built. What you see may change.

Calvinball Championship, Again 2

Time limit1sMemory limit256 MB

Summary
Split n players into the fewest teams so no pair who dislike each other shares a team.
Level

Hard9 of 10

Topics
Graph, Backtracking, Brute force
Solved
No attempts yet

Problem

A Calvinball game has nn players. Some pairs dislike each other (symmetrically). Split everyone into teams so no disliking pair shares a team, using as few teams as possible. Output any optimal division.

Input

Line 1: nn and mm, the player count and dislike-pair count. Next mm lines: distinct players aia_i and bib_i who dislike each other (1≤ai,bi≤n1 \leq a_i, b_i \leq n).

Output

Line 1: team count tt. Next tt lines list players on each team in any order. Teams and players within a team may appear in any order.

Note

Batch data may be judged separately; the sample above is a normal stdin/stdout case.

Examples4

  1. Example 1

    Input
    6 7
    1 6
    2 6
    3 6
    4 6
    5 6
    5 4
    2 4
    
    Expected output
    3
    6
    1 3 4
    2 5
    
  2. Example 2

    Input
    3 3
    1 2
    2 3
    1 3
    
    Expected output
    3
    1
    2
    3
    
  3. Example 3

    Input
    4 2
    1 2
    3 4
    
    Expected output
    2
    1 3
    2 4
    
  4. Example 4

    Input
    2 1
    1 2
    
    Expected output
    2
    1
    2