Maximum and minimum connected component

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 nn and the number of edges mm, followed by mm pairs xx yy that correspond to an edge between vertices xx and yy. It holds that 1n1041 \le n \le 10^4, 0m5n0 \le m \le 5n, vertices are numbered from 00 to n1n-1, and there are neither repeated edges nor edges of the form xx xx.

Output

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

Problem information

Author: Salvador Roura

Generation: 2026-01-25T22:04:35.504Z

© Jutge.org, 2006–2026.
https://jutge.org