Build Roads
Add the minimum number of two-way roads so every pair of cities becomes connected.
Input
The first line contains n and m. The next m lines contain existing roads.
1 <= n <= 1000
Output
Print k, then k roads. Use the smallest-numbered vertex of each component and connect consecutive representatives in increasing order.
Example
Input
6 3
1 2
2 3
5 6
Output
2
1 4
4 5
Comments