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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author prakharjain
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        EMinimalDiameterForest solver = new EMinimalDiameterForest();
        solver.solve(1, in, out);
        out.close();
    }

    static class EMinimalDiameterForest {
        boolean[] vis;
        Set<Integer> s = new HashSet<>();
        List[] g;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();

            int m = in.nextInt();

            g = new List[n];
            in.readUndirectedGraph(g, n, m, 1);

            vis = new boolean[n];

            List<Integer> centers = new ArrayList<>();

            int ans = 0;

            List<Integer> mxh = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                if (!vis[i]) {
                    s.clear();
                    dfs(i, -1);

                    List[] g2 = new List[n];

                    int root = -1;

                    for (int j = 0; j < n; j++) {
                        g2[j] = new ArrayList();

                        if (!s.contains(j))
                            continue;

                        root = j;

                        for (int k = 0; k < g[j].size(); k++) {
                            int v = (int) g[j].get(k);

                            if (s.contains(v)) {
                                g2[j].add(v);
                            }
                        }
                    }

                    DiameterTree dt = new DiameterTree(g2);
                    dt.dfs(root, -1, 0);
                    dt.dfs(dt.node1, -1, 0);
                    centers.add(dt.findCenter());

                    // ans = Math.max(ans, dt.dis);

                    mxh.add((dt.dis + 1) / 2);
                }
            }

//        mxh.sort(Comparator.reverseOrder());
//
//        if (mxh.size() >= 2) {
//            ans = Math.max(ans, mxh.get(0) + 1 + mxh.get(1));
//        }

            ans = n + 5;


            int fmp = -1;
            for (int j = 0; j < centers.size(); j++) {
                int mp = j;
                for (int i = 0; i < centers.size(); i++) {
                    if (i != mp) {
                        g[centers.get(mp)].add(centers.get(i));
                        g[centers.get(i)].add(centers.get(mp));
                    }
                }

                DiameterTree dt = new DiameterTree(g);
                dt.dfs(0, -1, 0);
                dt.dfs(dt.node1, -1, 0);

                if (dt.dis < ans) {
                    fmp = mp;
                    ans = dt.dis;
                }

                for (int i = 0; i < centers.size(); i++) {
                    if (i != mp) {
                        g[centers.get(mp)].remove(centers.get(i));
                        g[centers.get(i)].remove(centers.get(mp));
                    }
                }
            }

            out.println(ans);

            for (int i = 0; i < centers.size(); i++) {
                if (i != fmp)
                    out.println(centers.get(fmp) + 1 + " " + (centers.get(i) + 1));
            }
        }

        void dfs(int u, int p) {
            vis[u] = true;
            s.add(u);
            for (int i = 0; i < g[u].size(); i++) {
                int v = (int) g[u].get(i);

                if (v != p) {
                    dfs(v, u);
                }
            }
        }

        public class DiameterTree {
            List[] g;
            int node1;
            int dis = -1;
            int[] parent;

            public DiameterTree(List[] g) {
                this.g = g;
                this.parent = new int[g.length];
            }

            void dfs(int u, int p, int cmax) {
                if (cmax >= dis) {
                    node1 = u;
                    dis = cmax;
                }

                parent[u] = p;

                for (int edge : (List<Integer>) g[u]) {
                    int v = edge;
                    if (v != p)
                        dfs(v, u, cmax + 1);
                }
            }

            int findCenter() {
                int current = node1;

                for (int i = 0; i < dis / 2; i++) {
                    current = parent[current];
                }

                return current;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public void readUndirectedGraph(List[] g, int numOfVertices, int numOfEdges, int offset) {
            for (int i = 0; i < numOfVertices; i++) {
                g[i] = new ArrayList();
            }

            for (int i = 0; i < numOfEdges; i++) {
                int u = nextInt() - offset;
                int v = nextInt() - offset;

                g[u].add(v);
                g[v].add(u);
            }
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }
}