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;
const int INF = 1e9 + 10;
const long long int LINF = 1LL * INF * INF;
const int MAXN = 2e5 + 10;
const int MAXM = 3e3 + 10;
priority_queue<int> pq;
vector<vector<pair<int, int> > > graph;
queue<int> que;
int A[MAXN];
bool edge[MAXN];
pair<int, int> E[MAXN];
bool visited[MAXN];
bool group[MAXN];
int par[MAXN];
int root(int x) {
  if (x == par[x]) return x;
  return par[x] = root(par[x]);
}
bool mymerge(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return false;
  par[y] = x;
  return true;
}
void dfs(int here) {
  visited[here] = true;
  int there;
  int num;
  for (int i = 0; i < graph[here].size(); i++) {
    there = graph[here][i].first;
    if (visited[there]) continue;
    num = graph[here][i].second;
    edge[num] = true;
    dfs(there);
  }
  return;
}
int main() {
  int n, m, k, a, b, x, y, d;
  int sum = 0;
  int cnt = 0;
  int mx = 0;
  int mn = INF;
  cin >> n >> m >> d;
  graph = vector<vector<pair<int, int> > >(n + 1);
  for (int i = 1; i <= n; i++) par[i] = i;
  int component = n - 1;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    graph[x].push_back(pair<int, int>(y, i));
    graph[y].push_back(pair<int, int>(x, i));
    E[i] = pair<int, int>(x, y);
    if (min(x, y) == 1) continue;
    if (mymerge(x, y)) component--;
  }
  if ((int)graph[1].size() < d || component > d) {
    printf("NO\n");
    return 0;
  }
  visited[1] = true;
  int there, num, cur;
  cnt = d;
  for (int i = 0; i < graph[1].size(); i++) {
    there = graph[1][i].first;
    num = graph[1][i].second;
    cur = root(there);
    if (group[cur]) continue;
    group[cur] = true;
    visited[there] = true;
    edge[num] = true;
    cnt--;
    if (!cnt) break;
  }
  if (cnt) {
    for (int i = 0; i < graph[1].size(); i++) {
      there = graph[1][i].first;
      num = graph[1][i].second;
      if (visited[there]) continue;
      visited[there] = true;
      edge[num] = true;
      cnt--;
      if (!cnt) break;
    }
  }
  if (cnt) {
    printf("NO\n");
    return 0;
  }
  for (int i = 0; i < graph[1].size(); i++) {
    there = graph[1][i].first;
    if (visited[there]) dfs(there);
  }
  printf("YES\n");
  for (int i = 0; i < m; i++) {
    if (edge[i]) printf("%d %d\n", E[i].first, E[i].second);
  }
  return 0;
}