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 JAVA):

Solution:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

/**
 *
 * @author is2ac
 */
public class F_CF {

    public static void main(String[] args) {
        FastScanner60 fs = new FastScanner60();
        PrintWriter pw = new PrintWriter(System.out);
        //int t = fs.ni();
        int t = 1;
        for (int tc = 0; tc < t; tc++) {
            int n = fs.ni();
            int m = fs.ni();
            int k = fs.ni();
            int[][] edges = new int[m][2];
            for (int i = 0; i < m; i++) {
                edges[i] = fs.intArray(2);
                edges[i][0]--;
                edges[i][1]--;
            }
            UnionFind19 uf = new UnionFind19(n);
            for (int i = 0; i < m; i++) {
                if (edges[i][0]!=0 && edges[i][1]!=0) {
                    uf.union(edges[i][0],edges[i][1]);
                }
            }
            List<int[]> list = new ArrayList();
            int ct = 0, o = 0;
            for (int i = 0; i < m; i++) {
                if (edges[i][0]!=0 && edges[i][1]!=0) continue;
                o++;
                if (uf.find(edges[i][0])==uf.find(edges[i][1])) continue;
                ct++;
                uf.union(edges[i][0], edges[i][1]);
                list.add(edges[i]);
            }
            if (ct>k || o<k) {
                pw.println("NO");
                continue;
            }
            Set<Integer> set = new HashSet();
            for (int i= 0; i < n; i++) {
                set.add(uf.find(i));
            }
            if (set.size()!=1) {
                pw.println("NO");
                continue;
            }
            uf = new UnionFind19(n);
            for (int i = 0; i < list.size(); i++) {
                int[] a = list.get(i);
                uf.union(a[0], a[1]);
            }
            k -= list.size();
            for (int i = 0; i < m; i++) {
                if (k==0) continue;
                if (edges[i][0]!=0 && edges[i][1]!=0) continue;
                if (uf.find(edges[i][0])==uf.find(edges[i][1])) continue;
                k--;
                uf.union(edges[i][0], edges[i][1]);
                list.add(edges[i]);
            }
            for (int i = 0; i < m; i++) {
                if (edges[i][0]==0 || edges[i][1]==0) continue;
                if (uf.find(edges[i][0])!=uf.find(edges[i][1])) {
                    list.add(edges[i]);
                    uf.union(edges[i][0],edges[i][1]);
                }
            }
            pw.println("YES");
            for (int i = 0; i < list.size(); i++) {
                pw.println((list.get(i)[0]+1) + " " + (1+list.get(i)[1]));
            }
        }
        pw.close();
    }
}
class UnionFind19 {

    int[] id;

    public UnionFind19(int size) {
        id = new int[size];
        for (int i = 0; i < size; i++) {
            id[i] = i;
        }
    }

    public int find(int p) {
        int root = p;
        while (root != id[root]) {
            root = id[root];
        }
        while (p != root) {
            int next = id[p];
            id[p] = root;
            p = next;
        }
        return root;
    }

    public void union(int p, int q) {
        int a = find(p), b = find(q);
        if (a == b) {
            return;
        }
        id[b] = a;
    }
}

class FastScanner60 {

    BufferedReader br;
    StringTokenizer st;

    public FastScanner60() {
        br = new BufferedReader(new InputStreamReader(System.in), 32768);
        st = null;
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int ni() {
        return Integer.parseInt(next());
    }

    int[] intArray(int N) {
        int[] ret = new int[N];
        for (int i = 0; i < N; i++) {
            ret[i] = ni();
        }
        return ret;
    }

    long nl() {
        return Long.parseLong(next());
    }

    long[] longArray(int N) {
        long[] ret = new long[N];
        for (int i = 0; i < N; i++) {
            ret[i] = nl();
        }
        return ret;
    }

    double nd() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}