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:
/*Author: Satyajeet Singh, Delhi Technological University*/
import java.io.*;
import java.util.*;
import java.text.*; 
import java.lang.*;

public class Main {
/*********************************************Constants******************************************/
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));        
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static long mod=(long)1e9+7;
    static long mod1=998244353;
    static boolean sieve[];
    static ArrayList<Integer> primes;
    static ArrayList<Long> factorial;
    static HashSet<Integer> graph[];
/****************************************Solutions Begins*****************************************/
static class DSU{
    int dsu[];
    long dsu_size[];
    int unconnected=0;
    long curr=0;
    DSU(int n){
        dsu=new int[n];
        dsu_size=new long[n];
        Arrays.fill(dsu,-1);
        Arrays.fill(dsu_size,0l);
        unconnected=n-1;
        for(int i=1;i<=n-1;i++){
            makeSet(i);
        }
    }
    void makeSet(int v){
        dsu[v]=v;
        dsu_size[v]=1;
    }
    int findSet(int v){
        if(dsu[v]==v){
            return v;
        }
        int v1=findSet(dsu[v]);
        dsu[v]=v1;
        return v1;
    }
    long getSize(int s1){
        int a=findSet(s1);
        return dsu_size[a];
    }
    void union(int s1,int s2){
        int a=findSet(s1);
        int b=findSet(s2);
        if(a!=b){
            unconnected--;
            if(dsu_size[a]>dsu_size[b]){
                int temp=a;
                a=b;
                b=temp;
            }
            dsu[a]=b;
            dsu_size[b]+=dsu_size[a];
        }
    }
}
    static boolean vis[];
    static DSU connectedComponets;
    static void dfs(int start,int prev){
        if(prev!=1)
        connectedComponets.union(prev,start);
        vis[start]=true;
        for(int u:graph[start]){
            if(!vis[u]){
                dfs(u,start);
            }
        }
    }
    public static void main (String[] args) throws Exception {
        String st[]=br.readLine().split(" ");
        int n=Integer.parseInt(st[0]);
        int m=Integer.parseInt(st[1]);
        int D=Integer.parseInt(st[2]);
        Makegraph(n+1);
        connectedComponets=new DSU(n+1);
        DSU spanningTree=new DSU(n+1);
        vis=new boolean[n+1];
        int edge[]=new int[2*m];
        int deg=0;
        int ctr=0;
        for(int i=0;i<m;i++){
            st=br.readLine().split(" ");
            int a=Integer.parseInt(st[0]);
            int b=Integer.parseInt(st[1]);
            if(a!=1&&b!=1){
                addEdge(a,b);
                addEdge(b,a);
            }else{
                deg++;
            }
            edge[ctr]=a;
            edge[ctr+1]=b;
            ctr+=2;
        }
        int dis=0;
        vis[1]=true;
        for(int i=2;i<=n;i++){
            if(!vis[i]){
                dfs(i,1);
                dis++;
            }
        }
      //  debug(connectedComponets.dsu);
       // debug(edge);
        if(dis>D||deg<D){
            out.println("NO");
        }
        else{
            out.println("YES");
            int done=0;
            ArrayList<Integer> output=new ArrayList<>();
            for(int i=0;i<2*m;i+=2){
                int a=edge[i];
                int b=edge[i+1];
                if((a==1||b==1)&&connectedComponets.findSet(a)!=connectedComponets.findSet(b)){
                    spanningTree.union(b,a);
                    connectedComponets.union(b,a);
                    output.add(a);
                    output.add(b);
                    done++;
                }
            }
           // debug(spanningTree.dsu);
            for(int i=0;i<2*m;i+=2){
                if(done==D)break;
                int a=edge[i];
                int b=edge[i+1];
                if((a==1||b==1)&&spanningTree.findSet(a)!=spanningTree.findSet(b)){
                    spanningTree.union(b,a);
                    output.add(a);
                    output.add(b);
                    done++;
                }
            }           
            for(int i=0;i<2*m;i+=2){
                int a=edge[i];
                int b=edge[i+1];
                if(a!=1&&b!=1&&spanningTree.findSet(a)!=spanningTree.findSet(b)){
                    spanningTree.union(b,a);
                    output.add(a);
                    output.add(b);
                }
            }
            for(int i=0;i<output.size();i+=2){
                out.println(output.get(i)+" "+output.get(i+1));
            }
        }
/****************************************Solutions Ends**************************************************/
        out.flush();
        out.close();
    }
/****************************************Template Begins************************************************/
/***************************************Precision Printing**********************************************/
    static void printPrecision(double d){
        DecimalFormat ft = new DecimalFormat("0.00000000000000000"); 
        out.println(ft.format(d));
    }
/******************************************Graph*********************************************************/
    static void Makegraph(int n){
        graph=new HashSet[n];
        for(int i=0;i<n;i++){
            graph[i]=new HashSet<>();
        }
    }
    static void addEdge(int a,int b){
        graph[a].add(b);
    }    

/*********************************************PAIR********************************************************/
    static class PairComp implements Comparator<Pair>{
        public int compare(Pair p1,Pair p2){
            if(p1.u>p2.u){
                return 1;
            }
            else if(p1.u<p2.u){
                return -1;
            }
            else{
                return p1.v-p2.v;
            }
        }
    }
    static class Pair implements Comparable<Pair> {
        int u;
        int v;
        int index=-1;
        public Pair(int u, int v) {
            this.u = u;
            this.v = v;
        }
 
        public int hashCode() {
            int hu = (int) (u ^ (u >>> 32));
            int hv = (int) (v ^ (v >>> 32));
            return 31 * hu + hv;
        }
 
        public boolean equals(Object o) {
            Pair other = (Pair) o;
            return u == other.u && v == other.v;
        }
 
        public int compareTo(Pair other) {
            if(index!=other.index)
                return Long.compare(index, other.index);
            return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
        }
 
        public String toString() {
            return "[u=" + u + ", v=" + v + "]";
        }
    }

    static class PairCompL implements Comparator<Pairl>{
        public int compare(Pairl p1,Pairl p2){
            if(p1.u>p2.u){
                return 1;
            }
            else if(p1.u<p2.u){
                return -1;
            }
            else{
                return 0;
            }
        }
    }
    static class Pairl implements Comparable<Pair> {
            long u;
            long v;
            int index=-1;
            public Pairl(long u, long v) {
                this.u = u;
                this.v = v;
            }
    
            public int hashCode() {
                int hu = (int) (u ^ (u >>> 32));
                int hv = (int) (v ^ (v >>> 32));
                return 31 * hu + hv;
            }
    
            public boolean equals(Object o) {
                Pair other = (Pair) o;
                return u == other.u && v == other.v;
            }
    
            public int compareTo(Pair other) {
                if(index!=other.index)
                    return Long.compare(index, other.index);
                return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
            }
    
            public String toString() {
                return "[u=" + u + ", v=" + v + "]";
            }
        }
/*****************************************DEBUG***********************************************************/
    public static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
/************************************MODULAR EXPONENTIATION***********************************************/
    static long modulo(long a,long b,long c) {
        long x=1;
        long y=a;
        while(b > 0){
            if(b%2 == 1){
                x=(x*y)%c;
            }
            y = (y*y)%c; // squaring the base
            b /= 2;
        }
        return  x%c;
    }
/********************************************GCD**********************************************************/
    static long gcd(long x, long y)
    {
        if(x==0)
            return y;
        if(y==0)
            return x;
        long r=0, a, b;
        a = (x > y) ? x : y; // a is greater number
        b = (x < y) ? x : y; // b is smaller number
        r = b;
        while(a % b != 0)
        {
            r = a % b;
            a = b;
            b = r;
        }
        return r;
    }
/******************************************SIEVE**********************************************************/
    static void sieveMake(int n){
        sieve=new boolean[n];
        Arrays.fill(sieve,true);
        sieve[0]=false;
        sieve[1]=false;
        for(int i=2;i*i<n;i++){
            if(sieve[i]){
                for(int j=i*i;j<n;j+=i){
                    sieve[j]=false;
                }
            }
        }
        primes=new ArrayList<Integer>();
        for(int i=0;i<n;i++){
            if(sieve[i]){
                primes.add(i);
            }
        }        
    }
/********************************************End***********************************************************/
}