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.
#include <bits/stdc++.h>
using namespace std;
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0, lim - 1);
  return uid(rang);
}
long long mpow(long long base, long long exp);
long long power(long long a, long long b);
const long long mod = 998244353;
vector<int> g[300001];
struct node {
  set<int> s;
};
struct segTree {
  int arr[2001];
  int res[8003];
  int NO_OPERATION = 0;
  void init(int x, int lo, int hi) {
    if (lo == hi) {
      res[x] = arr[lo];
      return;
    }
    int mid = (lo + hi) / 2;
    init(2 * x, lo, mid);
    init(2 * x + 1, mid + 1, hi);
    update_point(x);
  }
  long long merge_results(long long a, long long b) { return a + b; }
  void point_modify(int x, int lo, int hi, int pos, int val) {
    if (lo == hi) {
      res[x] = val;
      return;
    }
    int mid = (lo + hi) / 2;
    if (pos <= mid)
      point_modify(2 * x, lo, mid, pos, val);
    else
      point_modify(2 * x + 1, mid + 1, hi, pos, val);
    update_point(x);
  }
  void update_point(int x) { res[x] = res[2 * x] + res[2 * x + 1]; }
  int query(int x, int lo, int hi, int l, int r) {
    if (lo > r || hi < l || res[x] == 0) return 0;
    if (hi == lo) return lo;
    int mid = (lo + hi) / 2;
    int res = query(2 * x + 1, mid + 1, hi, l, r);
    if (res != 0)
      return res;
    else
      return query(2 * x, lo, mid, l, r);
  }
  int sum_query(int x, int lo, int hi, int l, int r) {
    if (lo >= l && hi <= r) return res[x];
    if (lo > r || hi < l) return 0;
    int mid = (lo + hi) / 2;
    return sum_query(2 * x, lo, mid, l, r) +
           sum_query(2 * x + 1, mid + 1, hi, l, r);
  }
  int kth_one(int x, int lo, int hi, int k) {
    if (lo == hi) return lo;
    int v1 = res[2 * x];
    int mid = (lo + hi) / 2;
    if (k <= v1)
      return kth_one(2 * x, lo, mid, k);
    else
      return kth_one(2 * x + 1, mid + 1, hi, k - v1);
  }
};
struct FenwickTree {
  int arr[100];
  int n;
  void update(int i, int delta) {
    while (i <= n) {
      arr[i] += delta;
      i = i + (i & (-i));
    }
  }
  int sum(int i) {
    if (i == 0) return 0;
    int res = 0;
    while (i > 0) {
      res = res + arr[i];
      i -= (i & (-i));
    }
    return res;
  }
};
struct dsu {
  int par[1001];
  int size_set[1001];
  int get_par(int u) {
    vector<int> temp;
    while (par[u] != u) {
      temp.push_back(u);
      u = par[u];
    }
    for (int i : temp) par[i] = u;
    return u;
  }
  void union_set(int a, int b) {
    a = get_par(a);
    b = get_par(b);
    if (a == b) return;
    if (size_set[a] < size_set[b]) {
      int temp = a;
      a = b;
      b = temp;
    }
    par[b] = a;
    size_set[a] += size_set[b];
  }
};
int check(string s1, string s2) {
  int n1 = s1.size();
  int n2 = s2.size();
  s1 = '$' + s1;
  s2 = '$' + s2;
  int dp[n1 + 1][n2 + 1];
  for (int j = 0; j <= n2; j++) dp[0][j] = 0;
  dp[0][0] = 1;
  for (int i = 1; i <= n1; i++) {
    dp[i][0] = 0;
  }
  int i1 = 1;
  while (i1 <= n1 && s1[i1] == '*') {
    dp[i1][0] = 1;
    i1++;
  }
  int sum[n2 + 1];
  int s = 0;
  for (int i = 0; i <= n2; i++) s = s + dp[0][i], sum[i] = s;
  for (int i = 1; i <= n1; i++) {
    for (int j = 1; j <= n2; j++) {
      char c1 = s1[i];
      char c2 = s2[j];
      if (c1 == '*') {
        if (sum[j] > 0)
          dp[i][j] = 1;
        else
          dp[i][j] = 0;
      } else if (c1 == '?') {
        dp[i][j] = dp[i - 1][j - 1];
      } else {
        if (c1 != c2)
          dp[i][j] = 0;
        else
          dp[i][j] = dp[i - 1][j - 1];
      }
    }
    s = 0;
    for (int j = 0; j <= n2; j++) {
      s += dp[i][j];
      sum[j] = s;
    }
  }
  return dp[n1][n2];
}
int deg[200001];
int vis[200001];
vector<int> comp;
void dfs(int u) {
  vis[u] = 1;
  comp.push_back(u);
  for (int i : g[u]) {
    if (vis[i] == 0) dfs(i);
  }
}
vector<int> get_centroid(vector<int> comp) {
  if (comp.size() == 1) return comp;
  int vis1[200001];
  queue<int> q;
  for (int i : comp) {
    vis1[i] = 0;
    if (deg[i] == 1) q.push(i), vis1[i] = 1;
  }
  vector<int> cent;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    cent.clear();
    cent.push_back(u);
    for (int i : g[u]) {
      deg[i]--;
      if (vis1[i] == 0 && deg[i] == 1) q.push(i), vis1[i] = 1;
    }
  }
  return cent;
}
int vis1[200001];
int depth, deepest;
void dfs1(int u, int lvl) {
  vis1[u] = 1;
  if (lvl > depth) depth = lvl, deepest = u;
  for (int i : g[u]) {
    if (vis1[i] == 0) dfs1(i, lvl + 1);
  }
}
int get_diam(vector<int> comp) {
  depth = 0;
  deepest = comp[0];
  for (int i : comp) vis1[i] = 0;
  dfs1(comp[0], 0);
  depth = 0;
  for (int i : comp) vis1[i] = 0;
  dfs1(deepest, 0);
  return depth;
}
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) deg[i] = 0, vis[i] = 0;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    deg[u]++;
    deg[v]++;
  }
  vector<pair<int, int> > diam_cent;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      comp.clear();
      dfs(i);
      vector<int> cent = get_centroid(comp);
      int d = get_diam(comp);
      diam_cent.push_back(make_pair(d, cent[0]));
    }
  }
  int pos = -1;
  int mx_diam = -1;
  int cent_mx = -1;
  for (int i = 0; i < diam_cent.size(); i++) {
    if (diam_cent[i].first > mx_diam) {
      mx_diam = diam_cent[i].first;
      pos = i;
      cent_mx = diam_cent[i].second;
    }
  }
  vector<pair<int, int> > ed;
  for (int i = 0; i < diam_cent.size(); i++) {
    if (pos == i) continue;
    int d = diam_cent[i].first;
    int cent = diam_cent[i].second;
    g[cent].push_back(cent_mx);
    g[cent_mx].push_back(cent);
    ed.push_back(make_pair(cent, cent_mx));
  }
  vector<int> comp_temp;
  for (int i = 1; i <= n; i++) {
    comp_temp.push_back(i);
  }
  cout << get_diam(comp_temp) << "\n";
  for (auto i : ed) cout << i.first << " " << i.second << "\n";
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
long long mpow(long long base, long long exp) {
  base %= mod;
  long long result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((long long)result * base) % mod;
    base = ((long long)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b % 2 == 0) {
      b /= 2;
      a = a * a;
    } else {
      res = res * a;
      b--;
    }
  }
  return res;
}
