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;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const int N = 1010;
int visit[N];
vector<int> e[N];
void dfs(int now, vector<int> &d, vector<int> &p) {
  visit[now] = 1;
  for (int next : e[now]) {
    if (d[next] != -1) continue;
    d[next] = d[now] + 1;
    p[next] = now;
    dfs(next, d, p);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int u = in() - 1, v = in() - 1;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  vector<vector<int> > dia;
  for (int i = 0; i < n; ++i) {
    if (visit[i]) continue;
    vector<int> dist(n, -1), par(n, -1);
    dist[i] = 0;
    dfs(i, dist, par);
    int r = max_element((dist).begin(), (dist).end()) - dist.begin();
    dist.assign(n, -1), par.assign(n, -1);
    dist[r] = 0;
    dfs(r, dist, par);
    int x = max_element((dist).begin(), (dist).end()) - dist.begin();
    vector<int> tmp;
    do {
      tmp.push_back(x);
      x = par[x];
    } while (x != -1);
    dia.push_back(tmp);
  }
  m = dia.size();
  vector<pair<int, int> > p(m);
  for (int i = 0; i < m; ++i) p[i] = pair<int, int>(-dia[i].size(), i);
  sort((p).begin(), (p).end());
  vector<vector<int> > dia2(dia);
  for (int i = 0; i < m; ++i) dia[i] = dia2[p[i].second];
  int d = dia[0].size() - 1, d0 = d;
  int c = dia[0][d0 / 2];
  vector<pair<int, int> > ans;
  for (int i = 1; i <= m - 1; ++i) {
    int x = dia[i].size() - 1;
    ans.push_back(pair<int, int>(c, dia[i][x / 2]));
    d = max(d, (d0 + 1) / 2 + (x + 1) / 2 + 1);
    if (i >= 2) {
      d = max(d, (int)dia[1].size() / 2 + (x + 1) / 2 + 2);
    }
  }
  cout << d << endl;
  for (pair<int, int> p : ans)
    cout << p.first + 1 << " " << p.second + 1 << endl;
  return 0;
}