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.Collection;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.Queue;
import java.util.Comparator;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rustam Musin (t.me/musin_acm)
 */
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);
        ELesMinimalnogoDiametra solver = new ELesMinimalnogoDiametra();
        solver.solve(1, in, out);
        out.close();
    }

    static class ELesMinimalnogoDiametra {
        List<Integer>[] g;
        List<Component> components;
        List<Integer> curComponent;
        boolean[] used;
        int[] degree;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.readInt();
            int m = in.readInt();
            g = new List[n];
            for (int i = 0; i < n; i++) {
                g[i] = new ArrayList<>();
            }
            for (int i = 0; i < m; i++) {
                int u = in.readInt() - 1;
                int v = in.readInt() - 1;
                g[u].add(v);
                g[v].add(u);
            }
            degree = new int[n];

            used = new boolean[n];
            components = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                if (!used[i]) {
                    curComponent = new ArrayList<>();
                    build(i);
                    components.add(new Component(curComponent));
                }
            }
            components.sort(Comparator.comparingInt(c -> -c.diameter));
            List<IntIntPair> answer = new ArrayList<>();
            for (int i = 1; i < components.size(); i++) {
                answer.add(components.get(0).connect(components.get(i)));
            }
            out.printLine(components.get(0).diameter);
            for (IntIntPair p : answer) {
                out.printLine(p.first + 1, p.second + 1);
            }
        }

        void build(int v) {
            used[v] = true;
            curComponent.add(v);
            for (int to : g[v]) {
                if (!used[to]) {
                    build(to);
                }
            }
        }

        class Component {
            List<Integer> nodes;
            int depth0;
            int head;
            int diameter;

            Component(List<Integer> nodes) {
                this.nodes = nodes;
                findHead();
                IntIntPair res = findDiam(head, -1);
                depth0 = res.first;
                diameter = res.second;
            }

            void findHead() {
                for (int v : nodes) {
                    degree[v] = g[v].size();
                }
                Queue<Integer> q = new ArrayDeque<>();
                for (int v : nodes) {
                    if (degree[v] <= 1) {
                        q.add(v);
                    }
                }
                while (!q.isEmpty()) {
                    int v = q.poll();
                    head = v;
                    for (int to : g[v]) {
                        if (--degree[to] == 1) {
                            q.add(to);
                        }
                    }
                }
            }

            IntIntPair findDiam(int v, int p) {
                int dep = 0;
                int diam = 0;
                for (int to : g[v]) {
                    if (to == p) {
                        continue;
                    }
                    IntIntPair res = findDiam(to, v);
                    diam = Math.max(diam, res.second);
                    diam = Math.max(diam, dep + res.first + 1);
                    dep = Math.max(dep, 1 + res.first);
                }
                return IntIntPair.makePair(dep, diam);
            }

            IntIntPair connect(Component other) {
                diameter = Math.max(diameter, depth0 + other.depth0 + 1);
                if (depth0 == other.depth0) {
                    depth0++;
                }
                return IntIntPair.makePair(head, other.head);
            }

        }

    }

    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 printLine(Object... objects) {
            print(objects);
            writer.println();
        }

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

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

    }

    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 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 readInt() {
            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 static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        }

    }

    static class IntIntPair implements Comparable<IntIntPair> {
        public final int first;
        public final int second;

        public static IntIntPair makePair(int first, int second) {
            return new IntIntPair(first, second);
        }

        public IntIntPair(int first, int second) {
            this.first = first;
            this.second = second;
        }

        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (o == null || getClass() != o.getClass()) {
                return false;
            }

            IntIntPair pair = (IntIntPair) o;

            return first == pair.first && second == pair.second;
        }

        public int hashCode() {
            int result = first;
            result = 31 * result + second;
            return result;
        }

        public String toString() {
            return "(" + first + "," + second + ")";
        }

        public int compareTo(IntIntPair o) {
            int value = Integer.compare(first, o.first);
            if (value != 0) {
                return value;
            }
            return Integer.compare(second, o.second);
        }

    }
}