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 javafx.scene.layout.Priority;

import java.io.*;
import java.lang.reflect.Array;
import java.net.Inet4Address;
import java.util.*;
import java.lang.*;
import java.util.HashMap;
import java.util.PriorityQueue;
public class templ implements Runnable {
    public class triplet
    {
        int f,s,t;
        triplet(int f,int s,int t)
        {
            this.f=f;
            this.s=s;
            this.t=t;
        }
        public boolean equals(Object o)
        {
            triplet ob=(triplet)o;
            int ff,ss,tt;
            if(o!=null)
            {
                ff=ob.f;
                ss=ob.s;
                tt=ob.t;
                if((ff==this.f)&&(ss==this.s)&&(tt==this.t))
                    return true;
            }
            return false;
        }
        public int hashCode()
        {
            return (this.f+" "+this.s+" "+this.t).hashCode();
        }
    }
    public class pair implements Comparable
    {
        int f;
        int s;
        pair(int f,int s)
        {
            this.f=f;
            this.s=s;
        }
        public boolean equals(Object o)
        {
            pair ob=(pair)o;
            int ff;
            int ss;
            if(o!=null)
            {
                ff=ob.f;
                ss=ob.s;
                if((ff==this.f)&&(ss==this.s))
                    return true;
            }
            return false;
        }
        public int hashCode()
        {
            return (this.f+" "+this.s).hashCode();
        }
        public int compareTo(Object o)
        {
            pair pr=(pair)o;
            if(s>pr.s)
                return 1;
            else if(s==pr.s)
            {
                if(f<pr.f)
                    return -1;
                else
                    return 1;
            }
            else
                return -1;
        }
    }
    int n;
    int vis[],dist[],vis1[];
    ArrayList<Integer>g[];
    ArrayList<pair>al=new ArrayList<>();
    void bfs(int x)
    {
        Queue<Integer>q=new LinkedList<>();
        q.add(x);
        vis=new int[n+1];
        vis[x]=1;
        dist=new int[n+1];
        while(!q.isEmpty())
        {
            int u=q.remove();
            for(int v : g[u])
            {
                if(vis[v]==0)
                {
                    dist[v]=dist[u]+1;
                    vis[v]=1;
                    q.add(v);
                }
            }
        }
    }
    void solve(int x)
    {
        //System.out.println(x);
        bfs(x);
        int max=0,y=x;
        for(int i=1;i<=n;i++)
        {
            if(dist[i]>max)
            {
                max=dist[i];
                y=i;
            }
        }
        //System.out.println(" "+y);
        bfs(y);
        max=0;
        int yy=x;
        for(int i=1;i<=n;i++)
        {
            if(dist[i]>max)
            {
                max = dist[i];
                yy=i;
            }
        }
        //System.out.println(" "+max);
        int z=max/2;
        int zz=max-z;
        y=-1;
        ArrayList<Integer>all=new ArrayList<>();
        for(int i=1;i<=n;i++)
        {
            if(dist[i]==z)
            {
                all.add(i);
            }
        }
        bfs(yy);
        for(int i=0;i<all.size();i++)
        {
            int q=all.get(i);
            if(dist[q]==zz)
            {
                y=q;
                break;
            }
        }
        if(z==0)
            y=x;
        for(int i=1;i<=n;i++)
        {
            if(vis[i]==1)
                vis1[i]=1;
        }
        al.add(new pair(y,max));
    }
    public static void main(String args[])throws Exception
    {
        new Thread(null,new templ(),"templ",1<<27).start();
    }
    public void run() {
        try {
            InputReader in = new InputReader(System.in);
            PrintWriter out = new PrintWriter(System.out);
            n=in.ni();
            int m=in.ni();
            vis1=new int[n+1];
            g=new ArrayList[n+1];
            for(int i=1;i<=n;i++)
                g[i]=new ArrayList<>();
            for(int i=1;i<=m;i++)
            {
                int u=in.ni();
                int v=in.ni();
                g[u].add(v);
                g[v].add(u);
            }
            for(int i=1;i<=n;i++)
            {
                if(vis1[i]==0)
                    solve(i);
            }
            int v=-1,max=0;
            for(pair p : al)
            {
                if(p.s>=max)
                {
                    max=p.s;
                    v=p.f;
                }
            }
            int maxx=max;
            for(pair p : al)
            {
                if(p.f==v)
                {
                    continue;
                }
                maxx=Math.max(maxx,(int)Math.ceil((double)p.s/2)+(int)Math.ceil((double)maxx/2)+1);
            }
            out.println(maxx);
            for(pair p : al)
            {
                if(p.f==v)
                    continue;
                out.println(p.f+" "+v);
            }
            out.close();
        }
        catch(Exception e){
            return;
        }
    }
    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;

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

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

        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

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

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

    }
}