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:
	/*	/ ﾌﾌ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ム
		/ )\⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀  Y
		(⠀⠀| ( ͡° ͜ʖ ͡°）⠀⌒(⠀ ノ
		(⠀ ﾉ⌒ Y ⌒ヽ-く __／
		| _⠀｡ノ| ノ｡ |/
		(⠀ー '_人`ー ﾉ
		⠀|\ ￣ _人'彡ﾉ
		⠀ )\⠀⠀ ｡⠀⠀ /
		⠀⠀(\⠀ #⠀ /
		⠀/⠀⠀⠀/ὣ====================D-
		/⠀⠀⠀/⠀ \ \⠀⠀\
		( (⠀)⠀⠀⠀⠀ ) ).⠀)
		(⠀⠀)⠀⠀⠀⠀⠀( | /
		|⠀ /⠀⠀⠀⠀⠀⠀ | /
		[_] ⠀⠀⠀⠀⠀[___]                     */
	// Main Code at the Bottom
	import java.util.*;
	import java.lang.*;
	import java.io.*;
	import java.math.BigInteger; 
	public class Main {
		//Fast IO class
	    static class FastReader {
	        BufferedReader br; 
	        StringTokenizer st; 
	        public FastReader() {
	        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
	        	if(!env) {
	        		try {
						br=new BufferedReader(new FileReader("src\\input.txt"));
					} catch (FileNotFoundException e) {
						e.printStackTrace();
					}
	        	}
	        	else br = new BufferedReader(new InputStreamReader(System.in)); 
	        } 
	        String next() {
	            while (st == null || !st.hasMoreElements()) {
	                try {
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) {
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken(); 
	        } 
	        int nextInt() {
	            return Integer.parseInt(next()); 
	        } 
	        long nextLong() {
	            return Long.parseLong(next()); 
	        } 
	        double nextDouble() {
	            return Double.parseDouble(next()); 
	        } 
	        String nextLine() {
	            String str = ""; 
	            try {
	                str = br.readLine(); 
	            } 
	            catch (IOException e) {
	                e.printStackTrace(); 
	            } 
	            return str; 
	        } 
	    }     
	    static long MOD=1000000000+7;
	    //Euclidean Algorithm
	    static long gcd(long A,long B){
	    	return (B==0)?A:gcd(B,A%B);
	    }
	    //Modular Exponentiation
	    static long fastExpo(long x,long n){
	        if(n==0) return 1;
	        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
	        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
	    }
	    //Modular Inverse
	    static long inverse(long x) {
	    	return fastExpo(x,MOD-2);
	    }
	    //Prime Number Algorithm
	    static boolean isPrime(long n){
	        if(n<=1) return false;
	        if(n<=3) return true;
	        if(n%2==0 || n%3==0) return false;
	        for(int i=5;i*i<=n;i+=6) if(n%i==0 || n%(i+2)==0) return false;
	        return true;
	    }
	    //Reverse an array
	    static void reverse(int arr[],int l,int r){
	    	while(l<r) {
	    		int tmp=arr[l];
	    		arr[l++]=arr[r];
	    		arr[r--]=tmp;
	    	}
	    }
	    //Print array
	    static void print1d(int arr[]) {
	    	out.println(Arrays.toString(arr));
	    }
	    static void print2d(long arr[][]) {
	    	for(long a[]: arr) out.println(Arrays.toString(a));
	    }
	    // Pair
	    static class pair{
	    	int x,y;
	    	pair(int a,int b){
	    		this.x=a;
	    		this.y=b;
	    	}
	    	public boolean equals(Object obj) {
	    		if(obj == null || obj.getClass()!= this.getClass()) return false;
	            pair p = (pair) obj;
	            return (this.x==p.x && this.y==p.y);
	        }
	    	public int hashCode() {
	            return Objects.hash(x,y);
	        }
	    }
	    static FastReader sc=new FastReader();
	    static PrintWriter out=new PrintWriter(System.out);  
	    //Main function(The main code starts from here
	    static int find(int x) {
	    	if(parent[x]<0) return x;
	    	return parent[x]=find(parent[x]);
	    }
	    static boolean union(int a,int b) {
	    	a=find(a);b=find(b);
	    	if(a==b) return false;
	    	parent[a]=b;
	    	return true;
	    }
	    static int V,parent[],visited[];
	    static ArrayList<Integer> graph[];
	    static void init(int n){
	        V=n;
	        graph=new ArrayList[V];
	        visited=new int[n];
	        parent=new int[n];
	    	Arrays.fill(parent, -1);
	        for(int i=0;i<V;i++) graph[i]=new ArrayList<>();
	    }
	    static void addEdge(int src,int dest){
	        graph[src].add(dest);
	        graph[dest].add(src);
	    }
	    static void dfs(int s) {
	    	if(visited[s]==1) return;
	    	 visited[s]=1;
	    	 for(Integer x: graph[s]) dfs(x);
	    }
	    public static void main (String[] args) throws java.lang.Exception {
	    	int test;
	    	test=1;
	    	//test=sc.nextInt();
	    	while(test-->0){
	    		int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
	    		init(n);
	    		pair edges[]=new pair[m];
	    		ArrayList<pair> ans=new ArrayList<>();
	    		for(int i=0;i<m;i++) {
	    			int src=sc.nextInt()-1,dest=sc.nextInt()-1;
	    			edges[i]=new pair(src,dest);
	    			if(src!=0 && dest!=0) addEdge(src,dest);
	    		}
	    		for(pair e: edges) {
	    			if(e.x!=0 && e.y!=0) continue;
	    			int u=Math.min(e.x, e.y),v=Math.max(e.x, e.y);
	    			if(visited[v]==1) continue;
	    			dfs(v);
	    			ans.add(e);
	    			union(e.x,e.y);
	    			k--;
	    		}
	    		if(k<0) {
	    			out.println("NO");
	    			break;
	    		}
	    		for(pair e: edges) {
	    			if(k==0) break;
	    			if(e.x!=0 && e.y!=0) continue;
	    			if(union(e.x,e.y)) {
	    				ans.add(e);
	    				k--;
	    			}
	    		}
	    		if(k>0) {
	    			out.println("NO");
	    			break;
	    		}
	    		for(pair e: edges) {
	    			if(e.x==0 || e.y==0) continue;
	    			if(union(e.x,e.y)) ans.add(e);
	    		}
	    		if(ans.size()!=n-1) {
	    			out.println("NO");
	    			break;
	    		}
	    		else {
	    			out.println("YES");
	    			for(pair e: ans) out.println((e.x+1)+" "+(e.y+1));
	    		}
	    	}
	        out.flush();
	        out.close();
	    }
	}