You are given a forest — an undirected graph with n vertices such that each its connected component is a tree.

The diameter (aka "longest shortest path") of a connected undirected graph is the maximum number of edges in the shortest path between any pair of its vertices.

You task is to add some edges (possibly zero) to the graph so that it becomes a tree and the diameter of the tree is minimal possible.

If there are multiple correct answers, print any of them.

Input

The first line contains two integers n and m (1 ≤ n ≤ 1000, 0 ≤ m ≤ n - 1) — the number of vertices of the graph and the number of edges, respectively.

Each of the next m lines contains two integers v and u (1 ≤ v, u ≤ n, v ≠ u) — the descriptions of the edges.

It is guaranteed that the given graph is a forest.

Output

In the first line print the diameter of the resulting tree.

Each of the next (n - 1) - m lines should contain two integers v and u (1 ≤ v, u ≤ n, v ≠ u) — the descriptions of the added edges.

The resulting graph should be a tree and its diameter should be minimal possible.

For m = n - 1 no edges are added, thus the output consists of a single integer — diameter of the given tree.

If there are multiple correct answers, print any of them.

Examples

Input


4 2
1 2
2 3


Output


2
4 2


Input


2 0


Output


1
1 2


Input


3 2
1 3
2 3


Output


2

Note

In the first example adding edges (1, 4) or (3, 4) will lead to a total diameter of 3. Adding edge (2, 4), however, will make it 2.

Edge (1, 2) is the only option you have for the second example. The diameter is 1.

You can't add any edges in the third example. The diameter is already 2.
import java.io.*;
import java.util.*;
import java.math.*;
public class F {
	public static List<Integer> adj[];
	public static List<Integer> comp[];
	public static int dist[];
	public static int dist2[];
	public static boolean flag[];
	public static int sz[];
	public static int par[];
	public static int dia[];
	public static int cent[];
	public static int bst[];
	public static void main(String[] args)throws IOException {
		FastIO sc = new FastIO(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ans[][] = new int[n][2];
		dist = new int[n];
		dist2 = new int[n];
		sz = new int[n];
		par = new int[n];
		dia = new int[n];
		cent = new int[n];
		adj = new ArrayList[n];
		comp = new ArrayList[n];
		bst = new int[n];
		flag = new boolean[n];
		for(int i=0; i<n; ++i) {
			adj[i] = new ArrayList<>();
			comp[i] = new ArrayList<>();
		}
		int a = 0;
		int b = 0;
		for(int i=0; i<m; ++i) {
			a = sc.nextInt()-1;
			b = sc.nextInt()-1;
			adj[a].add(b);
			adj[b].add(a);
		}
		int maincent = 0;
		for(int i=0; i<n; ++i) {
			if(!flag[i]) {
				solve(i);
			}
		}
		int best = 0;
		int bestidx = 0;
		for(int i=0; i<n; ++i) {
			if(dia[i]>best) {
				best = dia[i];
				bestidx = i;
			}
		}
		int curr = 0;
		if(m==n-1) {
			System.out.println(dia[0]);
		}else {
			Arrays.fill(flag, false);
			for(int i=0; i<n; ++i) {
				if(!flag[i]) {
					for(int v: comp[i]) {
						flag[v] = true;
					}
					if(i!=bestidx) {
						ans[curr][0] = cent[i];
						ans[curr][1] = cent[bestidx];
						adj[cent[i]].add(cent[bestidx]);
						adj[cent[bestidx]].add(cent[i]);
						curr++;
					}
				}
			}
			Arrays.fill(flag, false);
			solve(0);
			System.out.println(dia[0]);
			for(int i=0; i<(n-1)-m; ++i) {
				System.out.println((ans[i][0]+1) + " " + (ans[i][1]+1));
			}
		}
		out.close();
	}
	public static void solve(int u) {
		ArrayDeque<Integer> ad = new ArrayDeque<>();
		ad.offer(u);
		comp[u].clear();
		dist[u] = 0;
		flag[u] = true;
		while(!ad.isEmpty()) {
			int v = ad.poll();
			comp[u].add(v);
			for(int k : adj[v]) {
				if(flag[k])continue;
				flag[k] = true;
				dist[k] = dist[v]+1;
				ad.offer(k);
			}
		}
		int mx = -1;
		int first = u;
		int second = u;
		
		for(int k: comp[u]) {
			if(dist[k]>mx) {
				first = k;
				mx = dist[k];
			}
			dist[k] =0;
			flag[k] = false;
		}
		ad.offer(first);
		flag[first] = true;
		while(!ad.isEmpty()) {
			int v = ad.poll();
			for(int k : adj[v]) {
				if(flag[k])continue;
				flag[k] = true;
				dist[k] = dist[v]+1;
				ad.offer(k);
			}
		}
		
		for(int k: comp[u]) {
			if(dist[k]>dia[u]) {
				dia[u] = dist[k];
				second= k;
			}
			flag[k] = false;
		}
		ad.offer(second);
		while(!ad.isEmpty()) {
			int v = ad.poll();
			for(int k : adj[v]) {
				if(flag[k])continue;
				flag[k] = true;
				dist2[k] = dist2[v]+1;
				ad.offer(k);
			}
		}
		for(int k: comp[u]) {
			if(dist[k]==(dia[u]/2)&&dist2[k]==(dia[u]-(dia[u]/2)))cent[u] = k;
		}
	}
	static class FastIO {
		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;
		public FastIO(String fileName) throws IOException {
			dis = new FileInputStream(fileName);
		}
		public FastIO(InputStream is) throws IOException {
			dis = is;
		}
		int nextInt() throws IOException {
			int ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
 
			return (negative) ? -ret : ret;
		}
		long nextLong() throws IOException {
			long ret = 0;
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}
			return (negative) ? -ret : ret;
		}
		byte nextByte() throws IOException {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}
		String next() throws IOException {
			StringBuffer ret = new StringBuffer();
 
			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}
 
			return ret.toString();
		}
	}
}
