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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

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

    static class EMinimalDiameterForest {
        int n;
        int m;
        ArrayList<Integer>[] a;
        boolean[] vis;
        boolean[] vis2;
        int[] par;
        ArrayList<int[]> trees;
        ArrayList<int[]> ans;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            a = new ArrayList[n + 1];
            for (int i = 1; i <= n; ++i) {
                a[i] = new ArrayList<>();
            }

            for (int i = 0; i < m; ++i) {
                int u = in.nextInt();
                int v = in.nextInt();
                a[u].add(v);
                a[v].add(u);
            }

            vis = new boolean[n + 1];
            vis2 = new boolean[n + 1];
            par = new int[n + 1];
            trees = new ArrayList<>();
            ans = new ArrayList<>();

            int d = 0;
            for (int i = 1; i <= n; ++i) {
                if (!vis[i]) {
                    Pair<Integer, Integer> ok = dfs2(dfs(i).f);

                    int centroid = ok.f;
                    d = Math.max(d, ok.s);
                    for (int j = 0; j < ok.s / 2; ++j) {
                        centroid = par[centroid];
                    }
                    if (centroid == 0) {
                        throw new RuntimeException();
                    }

                    trees.add(new int[]{centroid, (ok.s + 1) / 2});
                }
            }

            int best = Integer.MAX_VALUE, besti = -1;
            for (int j = 0; j < trees.size(); ++j) {
                int half = trees.get(j)[1];
                int dia = 0;
                ArrayList<Integer> fuck = new ArrayList<>();
                for (int k = 0; k < trees.size(); ++k) {
                    if (k != j) {
                        dia = Math.max(dia, half + 1 + trees.get(k)[1]);
                        fuck.add(trees.get(k)[1]);
                    }
                }
                fuck.sort(null);
                if (fuck.size() > 1) {
                    dia = Math.max(dia, 2 + fuck.get(fuck.size() - 1) + fuck.get(fuck.size() - 2));
                }

                if (dia < best) {
                    best = dia;
                    besti = j;
                }
            }

            int root = trees.get(besti)[0];
            int half = trees.get(besti)[1];
            ArrayList<Integer> fuck = new ArrayList<>();
            for (int k = 0; k < trees.size(); ++k) {
                if (k != besti) {
                    d = Math.max(d, half + 1 + trees.get(k)[1]);
                    ans.add(new int[]{root, trees.get(k)[0]});
                    fuck.add(trees.get(k)[1]);
                }
            }
            fuck.sort(null);
            if (fuck.size() > 1) {
                d = Math.max(d, 2 + fuck.get(fuck.size() - 1) + fuck.get(fuck.size() - 2));
            }

            out.println(d);
            for (int[] a : ans) {
                out.println(a[0] + " " + a[1]);
            }
        }

        private final Pair<Integer, Integer> dfs(int u) {
            vis[u] = true;

            Pair<Integer, Integer> ans = new Pair<>(u, 0);
            for (int v : a[u]) {
                if (!vis[v]) {
                    par[v] = u;
                    Pair<Integer, Integer> ok = dfs(v);
                    if (++ok.s > ans.s) {
                        ans = ok;
                    }
                }
            }

            return ans;
        }

        private final Pair<Integer, Integer> dfs2(int u) {
            vis2[u] = true;

            Pair<Integer, Integer> ans = new Pair<>(u, 0);
            for (int v : a[u]) {
                if (!vis2[v]) {
                    par[v] = u;
                    Pair<Integer, Integer> ok = dfs2(v);
                    if (++ok.s > ans.s) {
                        ans = ok;
                    }
                }
            }

            return ans;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1 << 12];
        private int curChar;
        private int numChars;

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

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException ex) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            int res = 0;

            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }

            throw new InputMismatchException();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }

    static class Pair<F extends Comparable<F>, S extends Comparable<S>> implements Comparable<Pair<F, S>> {
        public F f;
        public S s;

        public Pair() {
        }

        public Pair(F first, S second) {
            this.f = first;
            this.s = second;
        }

        public int compareTo(Pair<F, S> fsPair) {
            int cmp = f.compareTo(fsPair.f);
            if (cmp == 0)
                return s.compareTo(fsPair.s);
            return cmp;
        }

        public boolean equals(Object o) {
            if (o == null || o.getClass() != this.getClass())
                return false;
            return compareTo((Pair<F, S>) o) == 0;
        }

        public String toString() {
            return "First: " + f + ", Second: " + s;
        }

    }
}

