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 di[] = {-1, 0, 1, 0};
const int dj[] = {0, 1, 0, -1};
const int dl[] = {0, 0, 0, -1};
const int dr[] = {0, 0, -1, 0};
long long Inverse(long long a, long long MOD) {
  long long m = a, n = MOD;
  long long xm = 1, xn = 0;
  while (n != 0) {
    long long q = m / n;
    long long r = m - q * n;
    long long xr = xm - q * xn;
    m = n;
    xm = xn;
    n = r;
    xn = xr;
  }
  return (xm % MOD + MOD) % MOD;
}
int lg(long long x) {
  int res = 0;
  for (int i = 0; i < x; i++) {
    long long GT = (1ll << i);
    if (GT <= x) {
      res = i;
    } else {
      return res;
    }
  }
  return res;
}
long long GCD(long long a, long long b) {
  if (b == 0) {
    return abs(a);
  }
  return GCD(b, a % b);
}
long long sqr(long long x) { return x * x; }
long long nhan(long long a, long long b, long long module) {
  a %= module;
  b %= module;
  long long q = (long double)a * b / module;
  long long r = (a * b - q * module) % module;
  if (r < 0) {
    r += module;
  }
  return r;
}
long long MU(long long a, long long n, long long module) {
  long long res = 1;
  for (; n; n = n >> 1, a = nhan(a, a, module)) {
    if (n & 1) {
      res = nhan(res, a, module);
    }
  }
  return res;
}
void hamZ(string S, int z[]) {
  int n = S.size();
  for (int i = 0; i <= n; i++) {
    z[i] = 0;
  }
  int L = 1, R = 1;
  for (int i = 2; i <= n; i++) {
    if (i <= R) {
      z[i] = min(z[i - L + 1], R - i + 1);
    }
    while (i + z[i] <= n && S[z[i]] == S[i + z[i] - 1]) {
      z[i]++;
    }
    if (i + z[i] - 1 > R) {
      R = i + z[i] - 1;
      L = i;
    }
  }
}
void Sang(int N, vector<int> Uoc[]) {
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j += i) Uoc[j].push_back(i);
  }
}
const int N = 2e5 + 10;
const double sodu = 1e-9;
const long long oo = 1e18;
const int module = 998244353;
const int M = 1e9 + 7;
const int NN = (1 << 16);
int n, ts[N];
vector<int> a[N];
int KT[N], d[N];
int H[N];
int d1[N], m, Count = 0;
vector<int> stk[N];
void nhap() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
}
void DFS(int u) {
  if (u == 0) return;
  KT[u] = 1;
  stk[Count].push_back(u);
  for (int v : a[u]) {
    if (KT[v] == 0) {
      d[v] = d[u] + 1;
      DFS(v);
    }
  }
}
void rs() {
  for (int i = 1; i <= n; i++) KT[i] = d[i] = 0;
}
int Find_Center(int root) {
  stk[Count].clear();
  rs();
  DFS(root);
  int Left = root;
  for (int v : stk[Count]) {
    if (d[v] > d[Left]) Left = v;
  }
  for (int v : stk[Count]) KT[v] = d[v] = 0;
  stk[Count].clear();
  DFS(Left);
  int Right = root;
  for (int v : stk[Count]) {
    if (d[v] > d[Right]) Right = v;
    d1[v] = d[v];
  }
  for (int v : stk[Count]) KT[v] = d[v] = 0;
  stk[Count].clear();
  DFS(Right);
  for (int u : stk[Count]) {
    if (d[u] + d1[u] == d[Left] && abs(d[u] - d1[u]) <= 1) return u;
  }
}
void solve() {
  vector<pair<int, int> > KQ;
  Count = 0;
  int u = Find_Center(1);
  KQ.push_back(pair<int, int>(max(d1[u], d[u]), u));
  for (int i = 1; i <= n; i++) {
    if (KT[i] == 0) {
      Count++;
      int v = Find_Center(i);
      KQ.push_back(pair<int, int>(max(d1[v], d[v]), v));
    }
  }
  sort(KQ.begin(), KQ.end());
  reverse(KQ.begin(), KQ.end());
  vector<pair<int, int> > Noi;
  for (int i = 1; i < KQ.size(); i++) {
    int u = KQ[0].second;
    int v = KQ[i].second;
    Noi.push_back(pair<int, int>(KQ[0].second, KQ[i].second));
    a[u].push_back(v);
    a[v].push_back(u);
  }
  Count = 0;
  for (int i = 1; i <= n; i++) d1[i] = 0;
  Find_Center(1);
  int Res = 0;
  for (int i = 1; i <= n; i++) Res = max(Res, d[i]);
  cout << Res << '\n';
  for (pair<int, int> VC : Noi) {
    cout << VC.first << " " << VC.second << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  nhap();
  solve();
}