Problem: 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.

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.Collectors;


public class Main {

	static class Task {
		
		int NN = 1005;
		int MOD = 998244353;
		int INF = 2000000000;
		
		LinkedList<Integer> [] G;
		boolean [] visited;
		
		class DiameterAndCenter {
			Integer diameter;
			Integer center;
			public DiameterAndCenter(int d, int c) {
				this.diameter = d;
				this.center = c;
			}
		}
		
		class Edge {
			int u;
			int v;
			public Edge(int u, int v) {
				this.u = u;
				this.v = v;
			}
		}
		
		LinkedList [] height;
		
		public void solve(InputReader in, PrintWriter out) {
			int n = in.nextInt();
			G = new LinkedList[n + 1];
			visited = new boolean[n + 1];
			height = new LinkedList[n + 1];
			for(int i=1;i<=n;++i) {
				G[i] = new LinkedList<>();
				height[i] = new LinkedList<>();
				visited[i] = false;
			}
			int m = in.nextInt();
			for(int i=1;i<=m;++i) {
				int u = in.nextInt(), v = in.nextInt();
				G[u].add(v);G[v].add(u);
			}
			List<DiameterAndCenter> L = new ArrayList<>();
			for(int i=1;i<=n;++i) {
				if(visited[i])
					continue;
				L.add(getDiameterAndCenter(i, n));
			}
			L = L.stream().sorted((l1, l2) -> 
				l2.diameter.compareTo(l1.diameter))
					.collect(Collectors.toList());
			List<Edge> newEdgeList = new ArrayList<>();
			for(int i=1;i<L.size();++i) {
				newEdgeList.add(new Edge(L.get(0).center, L.get(i).center));
			}
			for(Edge e: newEdgeList) {
				G[e.u].add(e.v);
				G[e.v].add(e.u);
			}
			out.println(getDiameterAndCenter(1, n).diameter);
			for(Edge e: newEdgeList) {
				out.println(e.u + " " + e.v);
			}
		}
		
		DiameterAndCenter getDiameterAndCenter(int cur, int n) {
			for(int i=1;i<=n;++i) {
				visited[i] = false;
				height[i] = new LinkedList<>();
			}
			dfs(cur, -1);
			return dAndC(cur, -1);
		}
		
		DiameterAndCenter dAndC(int cur, int prev) {
			visited[cur] = true;
			DiameterAndCenter dc = new DiameterAndCenter(0, cur);
			int max1 = 0, max2 = 0;
			List<Integer> max1L = new LinkedList<>();
			List<Integer> max2L = new LinkedList<>();		
			for(int next: G[cur]) {
				if(next == prev)
					continue;
				if(height[next].size() > max1) {
					max2 = max1;max2L = new LinkedList<>(max1L);
					max1=height[next].size();max1L = height[next];
				} else if(height[next].size() > max2) {
					max2 = height[next].size();max2L=height[next];
				}
				DiameterAndCenter dc1 = dAndC(next, cur);
				if(dc1.diameter > dc.diameter) {
					dc.diameter = dc1.diameter;
					dc.center = dc1.center;
				}
			}
			if(max1 + max2 > dc.diameter) {
				dc.diameter = max1 + max2;
				Collections.reverse(max1L);
				max1L.add(cur);
				max1L.addAll(max2L);
				dc.center = max1L.get(max1L.size()/2);
			}
			return dc;
		}
		
		LinkedList<Integer> dfs(int cur, int prev) {
			height[cur] = new LinkedList<>();
			height[cur].add(cur);
			int mx = 0;
			LinkedList<Integer> mxh = new LinkedList<>();
			for(int next: G[cur]) {
				if(next == prev)
					continue;
				LinkedList<Integer> h = dfs(next, cur);
				if(h.size() + 1 > mx) {
					mx = h.size() + 1;
					mxh = h;
				}
			}
			for(int node: mxh) {
				height[cur].add(node);
			}
			return height[cur];
		}
	
	}
	
	static void prepareIO(boolean isFileIO) {
		Task solver = new Task();
		// Standard IO
		if(!isFileIO) {
			InputStream inputStream = System.in;
	        OutputStream outputStream = System.out;
	        InputReader in = new InputReader(inputStream);
	        PrintWriter out = new PrintWriter(outputStream);
	        solver.solve(in, out);
	        out.close();
		}
        // File IO
		else {
			String IPfilePath = System.getProperty("user.home") + "/Downloads/ip.in";
	        String OPfilePath = System.getProperty("user.home") + "/Downloads/op.out";
	        InputReader fin = new InputReader(IPfilePath);
	        PrintWriter fout = null;
	        try {
				fout = new PrintWriter(new File(OPfilePath));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
	        solver.solve(fin, fout);
	        fout.close();
		}
	}
	
	public static void main(String[] args) {
        prepareIO(false);
	}
	
	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }
        
        public InputReader(String filePath) {
        	File file = new File(filePath);
            try {
				reader = new BufferedReader(new FileReader(file));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
            tokenizer = null;
        }
        
        public String nextLine() {
        	String str = "";
        	try {
				str = reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        	return str;
        }
        
        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        
    }

}