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;
template <typename T>
void UpdateMax(T& a, T b) {
  if (a < b) a = b;
}
template <typename T>
void UpdateMin(T& a, T b) {
  if (a > b) a = b;
}
template <typename T>
inline void read(T& x) {
  x = 0;
  char c = getchar();
  int flag = 1;
  while (!isdigit(c)) {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= flag;
}
template <typename T>
void Unique(vector<T>& vec) {
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
}
template <typename T>
void Relabel(vector<T>& vec, T& value) {
  value = lower_bound(vec.begin(), vec.end(), value) - vec.begin() + 1;
}
template <typename T, typename V>
void Print(const pair<T, V>& x) {
  cout << x.first << " @ " << x.second << " | ";
}
template <typename T>
void Print(const T& x) {
  cout << x << " ";
}
template <typename T>
void Pcon(const T& x) {
  cout << "\nsize: " << x.size() << endl;
  for (const auto& item : x) Print(item);
}
std::vector<int> LABS;
template <typename T>
void Print(const T* x, int offset, int loop) {
  for (int i = 0; i <= loop; i++) {
    cout << "[";
    for (int item : LABS) cout << item - offset << ",";
    cout << i - offset << "]:";
    cout << x[i] << " ";
  }
}
template <typename T, typename... Args>
void Print(const T* f, int offset, int loop, Args... args) {
  for (int i = 0; i <= loop; i++) {
    LABS.push_back(i);
    Print(f[i], offset, args...);
    cout << endl;
    LABS.pop_back();
  }
}
template <typename T, typename V>
bool Has(T& cluster, const V& item) {
  return cluster.find(item) != cluster.end();
}
int Logn(long long x) {
  int cnt = 0;
  while (x) {
    ++cnt;
    x >>= 1;
  }
  return cnt;
}
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;
const int dir[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {1, 0}};
struct Edg {
  int x, y, z;
  friend bool operator<(const Edg& lhs, const Edg& rhs) {
    return lhs.z < rhs.z;
  }
} edg[N];
bool vis[N];
clock_t start_time;
int t, n, m;
int tot, root[N];
int _size[N];
vector<int> G[N];
inline void SetClock() { start_time = clock(); }
bool TimeOut(size_t ms) {
  if (1000 * (clock() - start_time) >= ms * ((clock_t)1000)) return true;
  return false;
}
inline pair<int, int> DeSerialize(int c) { return {(c) / m, (c) % m}; }
template <typename T, typename V>
inline void Add(T& v, const V& delta) {
  v += delta;
  if (v >= MOD) v -= MOD;
}
void dfs(int u) {
  vis[u] = true;
  for (int v : G[u]) {
    if (vis[v]) continue;
    dfs(v);
  }
}
int dfs1(int u, int fa, int& ret) {
  int maxDepth = 1;
  ret = u;
  for (int v : G[u]) {
    if (v == fa) continue;
    int retV;
    int retValue = dfs1(v, u, retV);
    if (retValue + 1 > maxDepth) {
      maxDepth = retValue + 1;
      ret = retV;
    }
  }
  return maxDepth;
}
void dfs2(int u, int v, int fa, vector<int>& tmp, vector<int>& vList) {
  tmp.emplace_back(u);
  if (u == v) {
    vList = tmp;
    return;
  }
  for (const auto& another : G[u]) {
    if (another == fa) continue;
    dfs2(another, v, u, tmp, vList);
  }
  tmp.pop_back();
}
pair<int, int> FetchCenter(int u) {
  int v, v2;
  dfs1(u, 0, v);
  dfs1(v, 0, v2);
  vector<int> vList, tmp;
  dfs2(v, v2, 0, tmp, vList);
  return {vList[vList.size() >> 1], vList.size() - 1};
}
void Merge(int x, int y) {
  auto t1 = FetchCenter(x).first;
  auto t2 = FetchCenter(y).first;
  edg[tot++] = {t1, t2, 0};
  G[t1].push_back(t2);
  G[t2].push_back(t1);
}
int main() {
  srand(time(0));
  SetClock();
  cin.sync_with_stdio(false);
  cin >> n >> m;
  for (int(i) = 0; (i) < (m); ++(i)) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  int cnt = 0;
  for (int(i) = 1; (i) <= (n); ++(i)) {
    if (!vis[i]) {
      root[cnt++] = i;
      dfs(i);
      _size[i] = FetchCenter(i).second;
    }
  }
  auto comp = [&](int lhs, int rhs) -> bool { return _size[lhs] > _size[rhs]; };
  sort(root, root + cnt, comp);
  for (int i = 1; i < cnt; i++) {
    Merge(root[0], root[i]);
  }
  cout << FetchCenter(1).second << endl;
  for (int(i) = 0; (i) < (tot); ++(i)) {
    cout << edg[i].x << " " << edg[i].y << endl;
  }
}
