Maximum and minimum connected component X68591


Statement
 

pdf   zip

html

Given an undirected graph, compute the number of vertices of the smallest and largest connected component.

Input

Input consists of several graphs. Each of them starts with the number of vertices n and the number of edges m, followed by m pairs x y that correspond to an edge between vertices x and y. It holds that 1 ≤ n ≤ 104, 0 ≤ m ≤ 5n, vertices are numbered from 0 to n−1, and there are neither repeated edges nor edges of the form x x.

Output

For each graph, write the minimum and maximum size of its connected components.

Public test cases
  • Input

    3 1  0 2
    1 0
    6 5  0 1  4 2  2 1  5 3  4 0
    

    Output

    1 2
    1 1
    2 4
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++