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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int C = 100001;
vector<vector<int> > tr(C);
int ij[C], a, b, n, ss = 0;
int check[C], d[C], rd[2][C], pd[C], bel[C];
int pom[C], pom2[C];
void Sebasort(int tab[], int tab2[], int l, int r) {
  int lim = 2, limi = l + 1, limj = l + 2, j = limi, i = l, k = l;
  while (lim / 2 <= r - l + 1) {
    while (i <= r) {
      if (limj > r) limj = r + 1;
      if ((j < limj && tab[j] < tab[i]) || i >= limi)
        pom[k] = tab[j], pom2[k] = tab2[j], j++;
      else
        pom[k] = tab[i], pom2[k] = tab2[i], i++;
      k++;
      if (i == limi && j == limj) limi += lim, limj += lim, i = j, j = limi;
    }
    for (i = l; i <= r; i++) tab[i] = pom[i], tab2[i] = pom2[i];
    lim *= 2, limi = l + lim / 2, limj = l + lim, j = limi, i = k = l;
  }
}
int s[C], is = 0, par[C], ji[C];
void proc_tree(int a, int n, vector<vector<int> > &tab, int ij[]) {
  s[0] = a, is = 1, check[a] = 1;
  int b, ad = 0, ard = a, i = 0;
  while (is > 0) {
    a = s[is - 1];
    if (ji[a] > 0 && tab[a][ji[a] - 1] == par[a]) ji[a]--;
    if (ji[a] > 0)
      b = s[is] = tab[a][ji[a] - 1], check[b] = 1, par[b] = a, is++, ji[a]--;
    else {
      if (rd[0][par[a]] < rd[0][a] + 1)
        rd[1][par[a]] = rd[0][par[a]], rd[0][par[a]] = rd[0][a] + 1,
        bel[par[a]] = a;
      else if (rd[1][par[a]] < rd[0][a] + 1)
        rd[1][par[a]] = rd[0][a] + 1;
      if (rd[0][a] + rd[1][a] > ad) ad = rd[0][a] + rd[1][a], ard = a;
      is--;
    }
  }
  while (ad < 2 * rd[0][ard]) ard = bel[ard];
  d[ss] = ad, pd[ss] = ard;
}
int fl(int a) {
  if (a % 2 == 0) return a / 2;
  return a / 2 + 1;
}
int main() {
  int wynn, i, m;
  scanf("%d %d", &n, &m);
  for (int z = 0; z < m; z++)
    scanf("%d %d", &a, &b), tr[a].push_back(b), tr[b].push_back(a), ij[a]++,
        ij[b]++;
  for (int z = 1; z <= n; z++) ji[z] = ij[z], par[z] = 0;
  for (i = 1; i <= n; i++)
    if (check[i] == 0) proc_tree(i, n, tr, ij), ss++;
  Sebasort(d, pd, 0, ss - 1);
  if (ss > 2) {
    wynn = max(fl(d[ss - 1]) + fl(d[ss - 2]) + 1, d[ss - 1]);
    wynn = max(wynn, fl(d[ss - 2]) + fl(d[ss - 3]) + 2);
  } else if (ss == 2)
    wynn = max(fl(d[ss - 1]) + fl(d[ss - 2]) + 1, d[ss - 1]);
  else
    wynn = d[ss - 1];
  printf("%d\n", wynn);
  for (i = 0; i < ss - 1; i++) printf("%d %d\n", pd[ss - 1], pd[i]);
  return 0;
}