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:
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Random;
import java.util.StringTokenizer;

import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.util.Arrays.fill;
import static java.util.Arrays.sort;

public class Main {
    FastScanner in;
    PrintWriter out;

    int[] parent;
    Random random = new Random();

    void dsuInit(int n) {
        parent = new int[n];
        for (int i = 0; i < n; i++)
            parent[i] = i;
    }

    int dsuGet(int v) {
        return v == parent[v] ? v : (parent[v] = dsuGet(parent[v]));
    }

    void dsuUnite(int a, int b) {
        a = dsuGet(a);
        b = dsuGet(b);

        if (a != b)
            if (random.nextBoolean())
                parent[a] = b;
            else
                parent[b] = a;
    }

    int n, m, D;

    private void solve() throws IOException {
        n = in.nextInt();
        m = in.nextInt();
        D = in.nextInt();

        dsuInit(n);
        ArrayList<Integer> ones = new ArrayList<>();
        int[][] e = new int[m][2];

        graph = new ArrayList[n];
        for (int i = 0; i < n; i++)
            graph[i] = new ArrayList<>();

        for (int i = 0; i < m; i++) {
            int v = in.nextInt() - 1, u = in.nextInt() - 1;
            e[i][0] = v;
            e[i][1] = u;
            graph[v].add(u);
            graph[u].add(v);
            if (v != 0 && u != 0) {
                dsuUnite(v, u);
            } else
                ones.add(max(v, u));
        }

        int cnt = 0;
        ans = new ArrayList<>();
        for (int u : ones)
            if (dsuGet(u) != dsuGet(0)) {
                dsuUnite(0, u);
                ans.add(0);
                ans.add(u);
                cnt++;
            }

        if (!(cnt <= D && D <= ones.size())) {
            out.println("NO");
            return;
        }

        out.println("YES");
        root = 0;
        p = new int[n];
        fill(p, -1);
        p[root] = -2;
        dfs(root);
    }

    ArrayList<Integer> ans;
    ArrayList<Integer>[] graph;
    int[] p;
    int root;

    private void dfs(int v) {
        if (v == root) {
            int cnt = 0;
            for (int u : ans)
                if (p[u] == -1) {
                    p[u] = v;
                    out.println(v + 1 + " " + (u + 1));
                    cnt++;
                }
            if (cnt < D)
                for (int u : graph[v])
                    if (p[u] == -1) {
                        p[u] = v;
                        out.println(v + 1 + " " + (u + 1));
                        if (++cnt == D)
                            break;
                    }
        } else
            for (int u : graph[v])
                if (p[u] == -1) {
                    p[u] = v;
                    out.println(v + 1 + " " + (u + 1));
                }

        for (int u : graph[v])
            if (p[u] == v)
                dfs(u);
    }

    class FastScanner {
        StringTokenizer st;
        BufferedReader br;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        boolean hasNext() throws IOException {
            return br.ready() || (st != null && st.hasMoreTokens());
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        boolean hasNextLine() throws IOException {
            return br.ready();
        }
    }

    private void run() throws IOException {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.flush();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}