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.util.*;
import java.lang.*;
import java.io.*;   
import java.math.*;
public class Prac{     
    static class InputReader { 
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        public InputReader(InputStream st) {
            this.stream = st;
        } 
        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } 
                catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        } 
        public long nl() {
            int c = read();
            while (isSpaceChar(c)) {
            c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        } 
        public int[] nia(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        } 
        public long[] nla(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        } 
        public Long[] nLa(int n) {
            Long a[] = new Long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        } 
        public String rs() {
            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 String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        } 
        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        } 
    }
    public static class Key {

        private final int x;
        private final int y;

        public Key(int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (!(o instanceof Key)) return false;
            Key key = (Key) o;
            return x == key.x && y == key.y;
        }

        @Override
        public int hashCode() {
            int result = x;
            result = 31 * result + y;
            return result;
        }

    }
    static class Pair implements Comparable<Pair>{
            int x,y;
            Pair(int a,int b){
                    x=a;y=b;
            }
            @Override
            public int compareTo(Pair p) {
                    if(x==p.x) return y-p.y;
                    return x-p.x;
            }
    }

    static PrintWriter w = new PrintWriter(System.out);
    static long mod1=998244353L,mod=1000000007;
    //static int r[]={0,1,0,-1}, c[]={1,0,-1,0};
    static int n,m,d,r[],p[];
    static ArrayList<Integer> arr[];
    static boolean v[];
    static int find(int i){
        if(i==p[i])return i;
        return p[i]=find(p[i]);
    }
    static void union(int a,int b){
        int x=find(a);
        int y=find(b);
        if(r[x]>=r[y]){
            r[x]+=r[y];
            p[y]=x;
        }
        else {
            r[y]+=r[x];
            p[x]=y;
        }
    }
    static void check(int i){
        if(v[i])return;
        v[i]=true;
        for(int j:arr[i]){
            union(i,j);
        }
        for(int j:arr[i]){
            if(!v[j]){
                check(j);
            }
        }
    }
    public static void main(String [] args){
        InputReader sc=new InputReader(System.in); 
        n=sc.ni();m=sc.ni();d=sc.ni();
        arr=new ArrayList[n+1];
        p=new int[n+1];
        r=new int[n+1];
        v=new boolean[n+1];
        for(int i=0;i<=n;i++){
            arr[i]=new ArrayList<>();
            p[i]=i;
            r[i]=1;
        }
        for(int i=0;i<m;i++){
            int u=sc.ni(),v=sc.ni();
            arr[u].add(v);arr[v].add(u);
        }
        if(arr[1].size()<d)w.println("NO");
        else{
            v[1]=true;
            ArrayList<Pair> ans=new ArrayList<>();
            for(int j:arr[1]){
                if(!v[j]){
                    check(j);
                    ans.add(new Pair(1,j));
                }
                
            }
            if(ans.size()>d)w.println("NO");
            else{
                Queue<Integer> q=new LinkedList<>();
                Arrays.fill(v,false);
                for(Pair p:ans){
                    v[p.x]=true;
                    v[p.y]=true;
                    q.add(p.y);
                }
                int rem=d-ans.size();
                for(int j:arr[1]){
                    if(rem>0&&!v[j]){
                        rem--;
                        v[j]=true;
                        ans.add(new Pair(1,j));
                        q.add(j);
                    }
                }
                while(!q.isEmpty()){
                    int size=q.size();
                    while(size-->0){
                        int x=q.poll();
                        //if(v[x])continue;
                        //v[x]=true;
                        for(int j:arr[x]){
                            if(!v[j]){
                                v[j]=true;
                                q.add(j);
                                ans.add(new Pair(x,j));
                            }
                        }
                    }
                }
                w.println("YES");
                for(Pair p:ans)w.println(p.x+" "+p.y);
            }
            
        }
        w.close();
    }
}