1050: Add edges to the graph
[Creator : ]
Description
Given a graph (undirected and unweighted) with N nodes and M edges, please find out how many edges we need to add to the graph so that there are edge between every pairs of the nodes.
Input
The first line contains two integers N and M
the next M lines, each line contains x and y which means there is an edge between node x and node y
(only one edge between any two nodes )
$ 1 \leq n \leq 10^5 $
$ 1 \leq m \leq 2*10^5 $
$ 1 \leq a, b \leq n $
the next M lines, each line contains x and y which means there is an edge between node x and node y
(only one edge between any two nodes )
$ 1 \leq n \leq 10^5 $
$ 1 \leq m \leq 2*10^5 $
$ 1 \leq a, b \leq n $
Output
the first line contains one integer K which is the number of edges need to be added
in the following K lines, each line has two integers x, y which is the edge should be add to node x and y.
(please arrange them in ascending order)
in the following K lines, each line has two integers x, y which is the edge should be add to node x and y.
(please arrange them in ascending order)
Sample Input Copy
3 2
1 2
2 3
Sample Output Copy
1
1 3