Graph Connectivity#5135

Graph Connectivity

1 second
122.174 megabytes
Very easy

You are given a graph with vertices and edges, where 1 \leq n \leq 1000 and 1 \leq m \leq 7000.

Your task is to determine the minimum number of edges that must be added to make the graph connected, and specify these edges.

Input

The input begins with the integers and , followed by pairs of integers. Each pair represents an edge in the graph, indicating the start and end vertices of that edge.

Output

First, output the minimum number of edges that need to be added. Then, for the next lines, provide the two vertices that form each new edge.

Examples

Example 1

Loading
Loading