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.*;
import java.util.*;

public class F2_SpanningTreeWithOneFixedDegree {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader inp = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(inp, out);
        out.close();
    }

    private static class Solver {
        private void solve(InputReader inp, PrintWriter out) {
            int n = inp.nextInt(), m = inp.nextInt(), d = inp.nextInt();
            ArrayList<Integer>[] graph = new ArrayList[n];
            DSU dsu = new DSU(n);
            for (int i = 0; i < n; i++) graph[i] = new ArrayList<>();
            for (int i = 0; i < m; i++) {
                int u = inp.nextInt() - 1, v = inp.nextInt() - 1;
                graph[u].add(v);
                graph[v].add(u);
                if (u != 0 && v != 0 && !dsu.sameSet(u, v)) dsu.union(u, v);
            }
            HashSet<Integer> set = new HashSet<>();
            for (int i = 1; i < n; i++) set.add(dsu.findParent(i));
            if (set.size() > d || graph[0].size() < d) {
                out.print("NO");
                return;
            }
            out.println("YES");
            boolean[] vis = new boolean[n];
            boolean[] conn = new boolean[n];
            vis[0] = true;
            for (int edge: graph[0]) {
                if (!dsu.sameSet(0, edge)) {
                    vis[edge] = true;
                    conn[edge] = true;
                    out.println((edge + 1) + " " + 1);
                    dsu.union(0, edge);
                    d--;
                }
            }
            for (int edge: graph[0]) {
                if (d <= 0) break;
                if (!vis[edge]) {
                    vis[edge] = true;
                    conn[edge] = true;
                    out.println((edge + 1) + " " + 1);
                    d--;
                }
            }
            Queue<Integer> queue = new LinkedList<>();
            for (int i = 1; i < n; i++) {
                if (vis[i]) {
                    vis[i] = false;
                    queue.add(i);
                }
            }
            while(!queue.isEmpty()) {
                int vertex = queue.poll();
                if (vis[vertex]) continue;
                vis[vertex] = true;

                for (int neigh: graph[vertex]) {
                    if (!vis[neigh]) {
                        if (!conn[neigh]) {
                            out.println((vertex + 1) + " " + (neigh + 1));
                            conn[neigh] = true;
                        }
                        queue.add(neigh);
                    }
                }
            }
        }
    }

    public static class DSU {
        private int[] parents, rank;

        public DSU(int n) {
            parents = new int[n];
            rank = new int[n];
            for (int i = 0; i < n; i++) parents[i] = -1;
        }

        public int findParent(int node) {
            if (parents[node] == -1) return node; //recursively search
            int parent = findParent(parents[node]);
            parents[node] = parent; //don't search another time for parent
            return parent;
        }

        public void union(int x, int y) {
            int xParent = findParent(x), yParent = findParent(y);
            if (rank[x] < rank[y]) parents[xParent] = yParent;
            else if (rank[x] > rank[y]) parents[yParent] = xParent;
            else {
                parents[yParent] = xParent;
                rank[xParent]++;
            }
        }

        public boolean sameSet(int x, int y) {
            return findParent(x) == findParent(y);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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