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.io.*;
 
import java.util.*;
 
 
 
public class Main {
	static boolean []exist;
    static PrintWriter pw = new PrintWriter(System.out);
    static ArrayList<Integer>[]arr;
    static int n,m,d;
	public static void main(String[] args) throws Exception {
 
		Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        m=sc.nextInt();
        d=sc.nextInt();
        p=new int[n];
        size=new int[n];
        Arrays.fill(size,1);
        for(int i=0;i<n;i++)p[i]=i+1;
        arr=new ArrayList[n+1];
        for(int i=0;i<=n;i++) {
        	arr[i]=new ArrayList<>();
        }
        exist=new boolean[n+1];
        for(int i=0;i<m;i++) {
        	int f=sc.nextInt();
        	int l=sc.nextInt();	
        	if(f==1) {
        		exist[l]=true;
        	}
        	if(l==1) {
        		exist[f]=true;
        	}
        	arr[f].add(l);
        	arr[l].add(f);
        }
        for(int i=2;i<=n;i++) {
        	for(int j=0;j<arr[i].size();j++) {
        	    int a=parent(i);
        	    int b=parent(arr[i].get(j));
        	    if(a!=b&&a!=1&&b!=1) {
        	    union(a,b);	
        	    }
        	}
        }
        int c=0;
        Stack<Integer>parent=new Stack<Integer>();
        for(int i=1;i<n;i++) {
        	if(p[i]==i+1) {
        		c++;
        		parent.add(i+1);
        	}
        }
        //pw.println(Arrays.toString(p));
        if(c>d||arr[1].size()<d) {System.out.println("NO");return;}
        boolean []v=new boolean[n+1];
        pw.println("YES");
        boolean []reach=new boolean[n+1];
        for(int i:parent) {
        	v[i]=true;
        	d--;
        	pw.println(1+" "+i);
        }
        reach[1]=true;
        v[1]=true;
        Stack<Integer>parent1=(Stack<Integer>)parent.clone();
        while(!parent.isEmpty()) {
        	int x=parent.pop();
        	for(int i:arr[x]) {
        		if(!reach[i]) {
        			parent.push(i);
        			reach[i]=true;
        		}
        	}
        }
        for(int i=0;i<arr[1].size();i++) {
        	if(d>0&&!reach[arr[1].get(i)]&&!v[arr[1].get(i)]) {
        		reach[i]=true;
        		parent1.add(arr[1].get(i));
        		v[arr[1].get(i)]=true;
        		pw.println(1+" "+arr[1].get(i));
        		d--;
        	}
        }
        for(int i=0;i<arr[1].size();i++) {
        	if(d>0&&!v[arr[1].get(i)]) {
        		v[arr[1].get(i)]=true;
        		parent1.add(arr[1].get(i));
        		pw.println(1+" "+arr[1].get(i));
        		d--;
        	}
        }
        reach=new boolean[n+1];
        reach[1]=true;
        while(!parent1.isEmpty()) {
        	int x=parent1.pop();
        	reach[x]=true;
        	for(int i:arr[x]) {
        		if(!reach[i]) {
        			parent1.push(i);
        			if(!v[i]) {
        			pw.println(x+" "+i);
        			v[i]=true;
        			}
        			reach[i]=true;
        		}
        	}
        }
        //pw.println(Arrays.toString(p));
		pw.close();
 
	}
	static int[]size;
	static int[]p;
	public static void union(int x,int y) {
		int f=x;
		int l=y;
		if(exist[l]) {p[f-1]=l;size[l-1]+=size[f-1];return;}
		if(exist[f]) {p[l-1]=f;size[f-1]+=size[l-1];return;}
		if(size[f-1]<size[l-1]) {
			p[f-1]=l;
			size[l-1]+=size[f-1];
		}
		else {
			p[l-1]=f;
			size[f-1]+=size[l-1];
		}
	}
	static int parent(int x) {
		if(p[x-1]==x) {
			return x;
		}
		return p[x-1]=parent(p[x-1]);
	}
public static boolean prime(int x){
	    int[] arr=new int[10000000];
	    int index=0;
	    int num=3;
	    int i=0;
	    arr[0]=2;
	    while(num<=x){
	      for(i=0;i<=index;i++){
	          if(num%arr[i]==0){
	              break;
	          }
	      }
	      if(i==index+1){
	          arr[++index]=num;
	      }
	      num++;
	    }
	    if(arr[index]==x)return true;
	    return false;
	      
	}
public static void conquer(int[] arr,int b,int m,int e){
	    int len1=m-b+1;
	    int len2=e-m;
	    int[] l=new int[len1];
	    int[] r=new int[len2];
	    for(int i=0;i<len1;i++){
	        l[i]=arr[b+i];
	    }
	   for(int j=0;j<len2;j++){
	            r[j]=arr[m+1+j];
	   }
	    int i=0,j=0,k=b;
	    while((i<len1)&&(j<len2)){
	        if(r[j]>=l[i]){
	            arr[k]=l[i];
	            k++;
	            i++;
	        }
	        else{
	           arr[k]=r[j];
	           k++;
	           j++;
	        }
	    }
	    while(i<len1){
	        arr[k++]=l[i++];
	    }
	    while(j<len2){
	        arr[k++]=r[j++];
	    }
	}
	static int mid;
	public static void sort(int[] arr,int b,int e){
	    if(b<e){
	        int mid =(e+b)/2;
	        sort(arr,b,mid);
	        sort(arr,mid+1,e);
	        conquer(arr,b,mid,e);
	    }
	}
    public static void Sort(int[] arr){
        sort(arr,0,arr.length-1);
    }
 
	static class Scanner {
 
		StringTokenizer st;
 
		BufferedReader br;
 
 
 
		public Scanner(InputStream s) {
 
			br = new BufferedReader(new InputStreamReader(s));
 
		}
 
 
 
		public Scanner(String file) throws FileNotFoundException {
 
			br = new BufferedReader(new FileReader(file));
 
		}
 
 
 
		public String next() throws IOException {
 
			while (st == null || !st.hasMoreTokens())
 
				st = new StringTokenizer(br.readLine());
 
			return st.nextToken();
 
		}
 
 
 
		public int nextInt() throws IOException {
 
			return Integer.parseInt(next());
 
		}
 
 
 
		public long nextLong() throws IOException {
 
			return Long.parseLong(next());
 
		}
 
 
 
		public String nextLine() throws IOException {
 
			return br.readLine();
 
		}
 
 
 
		public double nextDouble() throws IOException {
 
			return Double.parseDouble(next());
 
		}
 
 
 
		public boolean ready() throws IOException {
 
			return br.ready();
 
		}
 
 
 
	}
 
}