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;
vector<int> g[1005];
vector<set<int> > gg(1005);
vector<int> vv(1005);
vector<int> dis(1005), vis(1005);
int n, m, ans1, ct;
vector<int> temp;
vector<pair<int, int> > ans2;
struct T {
  vector<int> nodes;
  int c, k, d;
  T() {
    k = 0;
    d = 0;
  }
  void f() {
    if (nodes.size() == 1) {
      c = nodes.front();
      d = 0;
      return;
    }
    vector<int> l;
    for (auto i : nodes) {
      if (g[i].size() == 1) {
        l.push_back(i);
      }
    }
    while (l.size() >= 2) {
      vector<int> ee;
      for (auto i : l) {
        int x = *gg[i].begin();
        gg[x].erase(i);
        gg[i].erase(x);
        if (gg[x].size() == 1) {
          ee.push_back(x);
        }
      }
      l = ee;
    }
    c = l.front();
    return;
  }
  void bfs() {
    queue<int> q;
    int s = nodes.front();
    q.push(s);
    dis[s] = 0;
    vis[s] = 1;
    while (not q.empty()) {
      int u = q.front();
      q.pop();
      for (auto v : g[u]) {
        if (not vis[v]) {
          vis[v] = 1;
          dis[v] = dis[u] + 1;
          q.push(v);
        }
      }
    }
    int z = dis[nodes.front()], ss = nodes.front();
    for (auto u : nodes) {
      if (dis[u] > z) {
        z = dis[u];
        ss = u;
      }
      dis[u] = vis[u] = 0;
    }
    q.push(ss);
    vis[ss] = 1;
    dis[ss] = 0;
    while (not q.empty()) {
      int u = q.front();
      q.pop();
      for (auto v : g[u]) {
        if (not vis[v]) {
          vis[v] = 1;
          dis[v] = dis[u] + 1;
          q.push(v);
        }
      }
    }
    for (auto u : nodes) {
      d = max(d, dis[u]);
    }
    return;
  }
} tre[1005];
void bfs(int s) {
  queue<int> q;
  q.push(s);
  vv[s] = 1;
  while (not q.empty()) {
    int u = q.front();
    q.pop();
    temp.push_back(u);
    for (auto v : g[u]) {
      if (not vv[v]) {
        vv[v] = 1;
        q.push(v);
      }
    }
  }
  return;
}
void bbfs() {
  queue<int> q;
  q.push(0);
  for (int i = 0; i < n; i++) {
    dis[i] = vv[i] = 0;
  }
  dis[0] = 0;
  vv[0] = 1;
  while (not q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : g[u]) {
      if (not vv[v]) {
        vv[v] = 1;
        dis[v] = dis[u] + 1;
        q.push(v);
      }
    }
  }
  int z = 0, ss = 0;
  for (int i = 0; i < n; i++) {
    if (dis[i] > z) {
      z = dis[i];
      ss = i;
    }
    dis[i] = vv[i] = 0;
  }
  q.push(ss);
  vv[ss] = 1;
  dis[ss] = 0;
  while (not q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : g[u]) {
      if (not vv[v]) {
        vv[v] = 1;
        dis[v] = dis[u] + 1;
        q.push(v);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    ans1 = max(ans1, dis[i]);
  }
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    gg[u].insert(v);
    gg[v].insert(u);
    g[v].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    if (not vv[i]) {
      bfs(i);
      tre[ct++].nodes = temp;
      temp.clear();
    }
  }
  for (int i = 0; i < ct; i++) {
    tre[i].f();
    tre[i].bfs();
  }
  int mx = 0, cen = 0;
  for (int i = 0; i < ct; i++) {
    if (tre[i].d > mx) {
      cen = i;
      mx = tre[i].d;
    }
  }
  for (int i = 0; i < ct; i++) {
    if (i != cen) {
      ans2.push_back({tre[cen].c, tre[i].c});
      g[tre[cen].c].push_back(tre[i].c);
      g[tre[i].c].push_back(tre[cen].c);
    }
  }
  bbfs();
  cout << ans1 << '\n';
  for (auto i : ans2) {
    cout << i.first + 1 << ' ' << i.second + 1 << '\n';
  }
  return 0;
}