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:
// Don't place your source in a package
import javax.swing.*;
import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
import java.util.stream.Stream;


// Please name your class Main
public class Main {
    static FastScanner fs=new FastScanner();
    static class FastScanner {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next() {
            while (!st.hasMoreElements())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }
        int Int() {
            return Integer.parseInt(next());
        }

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

        String Str(){
            return next();
        }
    }


    public static void main (String[] args) throws java.lang.Exception {
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

        int T=1;
        for(int t=0;t<T;t++){
            int n=Int(),m=Int(),D=Int();
            int edges[][]=new int[m][2];
            for(int i=0;i<m;i++){
                edges[i][0]=Int()-1;
                edges[i][1]=Int()-1;
            }

            Solution sol=new Solution(out);
            sol.solution(n,edges,D);
        }
        out.close();

    }


    public static int Int(){
        return fs.Int();
    }
    public static long Long(){
        return fs.Long();
    }
    public static String Str(){
        return fs.Str();
    }

}






class Solution{
    PrintWriter out;
    public Solution(PrintWriter out){
        this.out=out;
    }



    public void solution(int n,int edges[][],int D){
        int cnt[]=new int[n];
        List<Integer>g[]=new ArrayList[n];
        List<int[]>res=new ArrayList<>();
        int nums[]=new int[n];

        for(int i=0;i<n;i++){
            nums[i]=i;
        }

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

        for(int e[]:edges){
            int u=e[0],v=e[1];
            cnt[u]++;cnt[v]++;
            g[u].add(v);g[v].add(u);
        }
        if(cnt[0]<D){
            out.println("NO");
            return;
        }



        for(int e[]:edges){
            int u=e[0],v=e[1];
            if(u==0||v==0)continue;
            int r1=find(nums,u);
            int r2=find(nums,v);
            if(r1!=r2)nums[r1]=r2;
        }

        Set<Integer>set=new HashSet<>();
        for(int u:g[0]){
            int r=find(nums,u);
            set.add(r);
        }

        if(set.size()>D){//strongly connect component
            out.println("NO");
            return;
        }


        Queue<Integer>q=new LinkedList<>();
        set.clear();
        cnt[0]=-1;
        for(int u:g[0]){
            int r=find(nums,u);
            if(D==0)break;
            if(!set.contains(r)){
                set.add(r);
                q.add(u);
                cnt[u]=-1;
                res.add(new int[]{1,u+1});
                D--;
            }
        }

        for(int u:g[0]){
            if(D==0)break;
            if(cnt[u]!=-1){
                cnt[u]=-1;
                q.add(u);
                res.add(new int[]{1,u+1});
                D--;
            }
        }





        while(q.size()>0){
            int top=q.poll();
            for(int next:g[top]){
                if(cnt[next]!=-1){
                    res.add(new int[]{top+1,next+1});
                    cnt[next]=-1;
                    q.add(next);
                }
            }
        }

        out.println("YES");
        for(int p[]:res){
            out.println(p[0]+" "+p[1]);
        }
    }

    public int find(int nums[],int x){//union find => find method
        if(nums[x]==x)return x;
        int root=find(nums,nums[x]);
        nums[x]=root;
        return root;
    }





}










/*
                             ;\
                            |' \
         _                  ; : ;
        / `-.              /: : |
       |  ,-.`-.          ,': : |
       \  :  `. `.       ,'-. : |
        \ ;    ;  `-.__,'    `-.|
         \ ;   ;  :::  ,::'`:.  `.
          \ `-. :  `    :.    `.  \
           \   \    ,   ;   ,:    (\
            \   :., :.    ,'o)): ` `-.
           ,/,' ;' ,::"'`.`---'   `.  `-._
         ,/  :  ; '"      `;'          ,--`.
        ;/   :; ;             ,:'     (   ,:)
          ,.,:.    ; ,:.,  ,-._ `.     \""'/
          '::'     `:'`  ,'(  \`._____.-'"'
             ;,   ;  `.  `. `._`-.  \\
             ;:.  ;:       `-._`-.\  \`.
              '`:. :        |' `. `\  ) \
      -hrr-      ` ;:       |    `--\__,'
                   '`      ,'
                        ,-'


                      free bug dog
*/