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.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
    static final long MOD = 1_000_000_007, INF = 1_000_000_000_000_000_000L;
    static final int INf = 1_000_000_000;
    static FastReader reader;
    static PrintWriter writer;
    public static void main(String[] args) {
        Thread t = new Thread(null, new O(), "Integer.MAX_VALUE", 100000000);
        t.start();
    }
    static class O implements Runnable {
        public void run() {
            try {
                magic();
            }
            catch (Exception e) {
                e.printStackTrace();
                System.exit(1);
            }
        }
    }
    static class FastReader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public FastReader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public FastReader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64];
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
            if (neg) return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead) fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null) return;
            din.close();
        }
    }
    //variables here
    static int in[], out[];
    static ArrayList<Integer> adj[];
    static boolean vis[];
    static ArrayList<Integer> components, centers, diameter;
    static void magic() throws IOException{
        reader = new FastReader();
        writer = new PrintWriter(System.out, true);
        int n = reader.nextInt();
        adj = new ArrayList[n+1];
        for(int i=1;i<=n;++i) {
            adj[i] = new ArrayList<>();
        }
        int m = reader.nextInt();
        for(int i=0;i<m;++i) {
            int u = reader.nextInt(), v = reader.nextInt();
            adj[u].add(v);
            adj[v].add(u);
        }
        vis = new boolean[n+1];
        in = new int[n+1];
        out = new int[n+1];
        centers = new ArrayList<>();
        diameter = new ArrayList<>();
        for(int i=1;i<=n;++i) {
            if(!vis[i]) {
                components = new ArrayList<>();
                dfs1(i,-1);
                dfs2(i,-1);
                int maxd = Integer.MIN_VALUE, mind = Integer.MAX_VALUE;
                int center = -1;
                for(int e : components) {
                    int ispe = max(in[e], out[e]);
                    if(maxd<ispe) {
                        maxd = ispe;
                    }
                    if(mind>ispe) {
                        mind = ispe;
                        center = e;
                    }
                }
                centers.add(center);
                diameter.add(maxd);
            }
        }
        int max_diameter = 0;
        for(int e : diameter) {
            max_diameter = max(max_diameter, e);
        }
        int globalcenter = -1;
        for(int i=0;i<diameter.size();++i) {
            if(diameter.get(i).equals(max_diameter)) {
                globalcenter = centers.get(i);
                break;
            }
        }
        ArrayList<Integer> edges_u = new ArrayList<>();
        ArrayList<Integer> edges_v = new ArrayList<>();
        for(int i=0;i<centers.size();++i) {
            if(centers.get(i).equals(globalcenter)) {
                continue;
            }
            edges_v.add(globalcenter);
            adj[centers.get(i)].add(globalcenter);
            edges_u.add(centers.get(i));
            adj[globalcenter].add(centers.get(i));
        }
        dfs1(1,1);
        dfs2(1,1);
        max_diameter = 0;
        for(int i=1;i<=n;++i) {
            max_diameter = max(max_diameter, max(in[i], out[i]));
        }
        writer.println(max_diameter);
        for(int i=0;i<edges_u.size();++i) {
            writer.println(edges_u.get(i)+" "+edges_v.get(i));
        }
    }
    static void dfs1(int node, int par) {
        components.add(node);
        vis[node] = true;
        int max = 0;
        for(int e : adj[node]) {
            if(e!=par) {
                dfs1(e, node);
                max = max(max, 1+in[e]);
            }
        }
        in[node] = max;
    }
    static void dfs2(int node, int par) {
        int mx1 = -1, mx2 = -1;
        for(int e : adj[node]) {
            if(e!=par) {
                if(in[e]>=mx1) {
                    mx2 = mx1;
                    mx1 = in[e];
                }
                else if(in[e]>mx2) {
                    mx2 = in[e];
                }
            }
        }
        for(int e : adj[node]) {
            if(e!=par) {
                out[e] = 1+out[node];
                if(in[e]!=mx1) {
                    out[e] = max(out[e], 2+mx1);
                }
                else {
                    out[e] = max(out[e], 2+mx2);
                }
                dfs2(e, node);
            }
        }
    }
}