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 javafx.util.Pair;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class problem1 {

    boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null);

    public problem1() throws IOException {
        InputReader in;
        if (ONLINE_JUDGE) {
            in = new InputReader(System.in);
        } else {
            in = new InputReader(new FileInputStream("input.txt"));
        }
        PrintWriter out = new PrintWriter(System.out);

        int T = 1;
        for (int caseNo = 1; caseNo <= T; caseNo++) {
            solve(caseNo, in, out);
        }

        out.close();
    }

    void dfs(List<Integer> used, List<List<Integer>> adj, List<Pair<Integer, Integer>> ans, int cur, int clr) {
        used.set(cur, clr);

        for (int v : adj.get(cur)) {
            if (used.get(v) == -1) {
                if (ans != null) ans.add(new Pair(cur, v));

                dfs(used, adj, ans, v, clr);
            }
        }
    }


    private void solve(int caseNo, InputReader in, PrintWriter out) throws IOException {

        int n = in.nextInt(), m = in.nextInt(), d = in.nextInt();

        List<Integer> used = new ArrayList<>(), used2 = new ArrayList<>();
        List<List<Integer>> adj = new ArrayList<>(n);

        List<Pair<Integer, Integer>> ans = new ArrayList<>();
        for (int i = 0; i < n; ++i) {
            adj.add(new ArrayList<>());
            used.add(-1);
            used2.add(-1);
        }

        for (int i = 0; i < m; ++i) {
            int u = in.nextInt(), v = in.nextInt();
            u--; v--;

            adj.get(u).add(v);
            adj.get(v).add(u);
        }

        int groupsCount = 0;
        Set<Integer> groups = new HashSet<>();
        used.set(0, 0);

        for (int v : adj.get(0)) {
            if (used.get(v) == -1) {
                dfs(used, adj, null, v, groupsCount);
                groups.add(groupsCount);
                groupsCount++;
            }
        }


        if (groupsCount <= d && adj.get(0).size() >= d) {
            used2.set(0,0);

            for (int v : adj.get(0)) {
                if (groups.contains(used.get(v))) {
                    groups.remove(used.get(v));

                    ans.add(new Pair(0, v));
                    used2.set(v, 0);

                }
            }

            for (int v : adj.get(0)) {
                if (groupsCount < d && used2.get(v) == -1) {
                    ans.add(new Pair(0, v));
                    used2.set(v, 0);
                    groupsCount++;
                }
            }

            for (int v : adj.get(0)) {
                if (used2.get(v) != -1) {
                    dfs(used2, adj, ans, v, 0);
                }
            }

            out.println("YES");


            for (int i = 0; i < n - 1; i++) {
                out.println(String.format("%d %d", ans.get(i).getKey() + 1, ans.get(i).getValue() + 1));
            }
        }  else {
            out.println("NO");
        }



    }

    static class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public interface SpaceCharFilter {

            public boolean isSpaceChar(int ch);
        }

        public String next() {
            return nextString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public Long nextLong() {
            return Long.parseLong(nextString());
        }

        public Double nextDouble() {
            return Double.parseDouble(nextString());
        }

        public char nextCharacter() {
            return nextString().charAt(0);
        }

        public int[] nextIntArray(int N) {
            int A[] = new int[N];
            for (int i = 0; i < N; i++) {
                A[i] = nextInt();
            }
            return A;
        }

        public long[] nextLongArray(int N) {
            long A[] = new long[N];
            for (int i = 0; i < N; i++) {
                A[i] = nextLong();
            }
            return A;
        }

        public double[] nextDoubleArray(int N) {
            double A[] = new double[N];
            for (int i = 0; i < N; i++) {
                A[i] = nextDouble();
            }
            return A;
        }
    }

    int min(int... a) {
        int min = Integer.MAX_VALUE;
        for (int v : a) {
            min = Math.min(min, v);
        }
        return min;
    }

    long min(long... a) {
        long min = Long.MAX_VALUE;
        for (long v : a) {
            min = Math.min(min, v);
        }
        return min;
    }

    double min(double... a) {
        double min = Double.MAX_VALUE;
        for (double v : a) {
            min = Math.min(min, v);
        }
        return min;
    }

    int max(int... a) {
        int max = Integer.MIN_VALUE;
        for (int v : a) {
            max = Math.max(max, v);
        }
        return max;
    }

    long max(long... a) {
        long max = Long.MIN_VALUE;
        for (long v : a) {
            max = Math.max(max, v);
        }
        return max;
    }

    double max(double... a) {
        double max = Double.MIN_VALUE;
        for (double v : a) {
            max = Math.max(max, v);
        }
        return max;
    }

    private void debug(Object... o) {
        if (ONLINE_JUDGE) {
            return;
        }
        System.out.println(Arrays.deepToString(o));
    }

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