Problem: You are given an undirected unweighted connected graph consisting of n vertices and m edges. It is guaranteed that there are no self-loops or multiple edges in the given graph.

Your task is to find any spanning tree of this graph such that the degree of the first vertex (vertex with label 1 on it) is equal to D (or say that there are no such spanning trees). Recall that the degree of a vertex is the number of edges incident to it.

Input

The first line contains three integers n, m and D (2 ≤ n ≤ 2 ⋅ 10^5, n - 1 ≤ m ≤ min(2 ⋅ 10^5, (n(n-1))/(2)), 1 ≤ D < n) — the number of vertices, the number of edges and required degree of the first vertex, respectively.

The following m lines denote edges: edge i is represented by a pair of integers v_i, u_i (1 ≤ v_i, u_i ≤ n, u_i ≠ v_i), which are the indices of vertices connected by the edge. There are no loops or multiple edges in the given graph, i. e. for each pair (v_i, u_i) there are no other pairs (v_i, u_i) or (u_i, v_i) in the list of edges, and for each pair (v_i, u_i) the condition v_i ≠ u_i is satisfied.

Output

If there is no spanning tree satisfying the condition from the problem statement, print "NO" in the first line.

Otherwise print "YES" in the first line and then print n-1 lines describing the edges of a spanning tree such that the degree of the first vertex (vertex with label 1 on it) is equal to D. Make sure that the edges of the printed spanning tree form some subset of the input edges (order doesn't matter and edge (v, u) is considered the same as the edge (u, v)).

If there are multiple possible answers, print any of them.

Examples

Input


4 5 1
1 2
1 3
1 4
2 3
3 4


Output


YES
2 1
2 3
3 4


Input


4 5 3
1 2
1 3
1 4
2 3
3 4


Output


YES
1 2
1 3
4 1


Input


4 4 3
1 2
1 4
2 3
3 4


Output


NO

Note

The picture corresponding to the first and second examples: <image>

The picture corresponding to the third example: <image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline char gc() { return getchar(); }
template <class T>
int read(T &ans) {
  ans = 0;
  char ch = gc();
  T f = 1;
  while (!isdigit(ch)) {
    if (ch == EOF) return -1;
    if (ch == '-') f = -1;
    ch = gc();
  }
  while (isdigit(ch)) ans = ans * 10 + ch - '0', ch = gc();
  ans *= f;
  return 1;
}
template <class T1, class T2>
int read(T1 &a, T2 &b) {
  return read(a) != EOF && read(b) != EOF ? 2 : EOF;
}
template <class T1, class T2, class T3>
int read(T1 &a, T2 &b, T3 &c) {
  return read(a, b) != EOF && read(c) != EOF ? 3 : EOF;
}
const int Maxn = 1100000;
const int inf = 0x3f3f3f3f;
int n, m, D, to[Maxn], nxt[Maxn], first[Maxn], tot = 1;
int vis[Maxn], d[Maxn], u, v, cnt;
queue<int> q;
vector<int> vi[Maxn];
inline void add(int u, int v) {
  to[tot] = v;
  nxt[tot] = first[u];
  first[u] = tot++;
  to[tot] = u;
  nxt[tot] = first[v];
  first[v] = tot++;
}
void dfs(int root) {
  vis[root] = cnt;
  for (int i = first[root]; i; i = nxt[i])
    if (!vis[to[i]]) dfs(to[i]);
}
signed main() {
  read(n, m, D);
  for (int i = 1; i <= m; i++) {
    read(u, v);
    add(u, v);
    d[u]++;
    d[v]++;
  }
  if (d[1] >= D && D) {
    vis[1] = ++cnt;
    for (int i = first[1]; i; i = nxt[i])
      if (vis[to[i]])
        vi[vis[to[i]]].push_back(to[i]);
      else
        cnt++, dfs(to[i]), vi[cnt].push_back(to[i]);
    if (cnt - 1 > D)
      puts("NO");
    else {
      memset(vis, 0, sizeof(vis));
      vis[1] = 1;
      puts("YES");
      for (int i = 2; i <= cnt; i++)
        printf("1 %d\n", vi[i][0]), vis[vi[i][0]] = 1, q.push(vi[i][0]);
      D -= cnt - 1;
      for (int i = 2; i <= cnt; i++) {
        for (int j = 1; j < vi[i].size(); j++) {
          if (!D) break;
          D--;
          printf("1 %d\n", vi[i][j]);
          vis[vi[i][j]] = 1;
          q.push(vi[i][j]);
        }
      }
      while (!q.empty()) {
        int now = q.front();
        q.pop();
        for (int i = first[now]; i; i = nxt[i])
          if (!vis[to[i]]) {
            vis[to[i]] = 1;
            printf("%d %d\n", now, to[i]);
            q.push(to[i]);
          }
      }
    }
  } else
    puts("NO");
  return 0;
}