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 int[] p, rank, setSize;
	static int numSets,N;
	public static int findSet(int i) { return p[i] == i ? i : (p[i] = findSet(p[i])); }

	public static boolean isSameSet(int i, int j) { return findSet(i) == findSet(j); }

	public static boolean unionSet(int i, int j) 
	{ 
		if (isSameSet(i, j)) 
			return false;
		numSets--; 
		int x = findSet(i), y = findSet(j);
		if(rank[x] > rank[y]) { p[y] = x; setSize[x] += setSize[y]; }
		else
		{	p[x] = y; setSize[y] += setSize[x];
			if(rank[x] == rank[y]) rank[y]++; 
		} 
		return true;
	}
	static HashSet<Integer>[]adj;
	static HashSet<Integer>curSubtree;
	static TreeMap<int[],Integer>mapEdges;
	static void dfs(int i,int par) {
		curSubtree.add(i);
		for(int j:adj[i]) {
			if(j!=par) {
				dfs(j, i);
			}
		}
	}
	public static void main(String[] args) throws Exception{
		PrintWriter pw=new PrintWriter(System.out);
		MScanner sc = new MScanner(System.in);
		int n=N=sc.nextInt(),m=sc.nextInt(),d=sc.nextInt();
		p = new int[numSets = N];
		rank = new int[N];
		setSize = new int[N];
		for (int i = 0; i < N; i++) {  p[i] = i; setSize[i] = 1; }
		int[][]edges=new int[m][];
		adj=new HashSet[n];
		boolean[]taken=new boolean[m];
		mapEdges=new TreeMap<int[],Integer>((x,y)->x[0]==y[0]?x[1]-y[1]:x[0]-y[0]);
		for(int i=0;i<n;i++)adj[i]=new HashSet();
		for(int i=0;i<m;i++) {
			int x=sc.nextInt()-1,y=sc.nextInt()-1;
			mapEdges.put(new int[] {x,y}, i);
			mapEdges.put(new int[] {y,x}, i);
			edges[i]=new int[] {x,y};
			if((x==0 || y==0) && adj[0].size()<d) {
				if(unionSet(x, y)) {
					adj[x].add(y);
					adj[y].add(x);
					taken[i]=true;
				}
			}
		}
		
		for(int i=0;i<m;i++) {
			int x=edges[i][0],y=edges[i][1];
			if(x!=0 && y!=0 && unionSet(x, y)) {
				adj[x].add(y);
				adj[y].add(x);
				taken[i]=true;
			}
		}
		for(int i=0;i<m;i++) {
			int x=edges[i][0],y=edges[i][1];
			if((x==0 || y==0) && unionSet(x, y)) {
				adj[x].add(y);
				adj[y].add(x);
				taken[i]=true;
			}
		}
		if(adj[0].size()<d || numSets!=1) {
			pw.println("NO");
			pw.flush();
			return;
		}
		LinkedList<Integer>[]adjNotTaken=new LinkedList[n];
		for(int i=0;i<n;i++)adjNotTaken[i]=new LinkedList<>();
		for(int i=0;i<m;i++) {
			if(!taken[i]) {
				int x=edges[i][0],y=edges[i][1];
				adjNotTaken[x].add(y);
				adjNotTaken[y].add(x);
			}
		}
		int k=adj[0].size();
		for(int j:adj[0]) {
			if(k==d)break;
			curSubtree=new HashSet<>();
			curSubtree.add(0);
			dfs(j, 0);
			int []canConnect=new int[] {-1,-1};
			outer:for(int i:curSubtree) {
				if(i==0)continue;
				for(int o:adjNotTaken[i]) {
					if(!curSubtree.contains(o)) {
						canConnect=new int[] {i,o};
						break outer;
					}
				}
			}
			if(canConnect[0]==-1)continue;
			int x=canConnect[0],y=canConnect[1];
			adj[x].add(y);
			adj[y].add(x);
			taken[mapEdges.get(new int[] {x,y})]=true;
			adj[j].remove(0);
			taken[mapEdges.get(new int[] {0,j})]=false;
			k--;
		}
		if(k!=d) {
			pw.println("NO");
			pw.flush();
			return;
		}
		pw.println("YES");
		for(int i=0;i<m;i++) {
			if(taken[i]) {
				pw.println((edges[i][0]+1)+" "+(edges[i][1]+1));
			}
		}
		
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			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[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		static void shuffle(int[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				int tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		static void shuffle(long[]in) {
			for(int i=0;i<in.length;i++) {
				int idx=(int)(Math.random()*in.length);
				long tmp=in[i];
				in[i]=in[idx];
				in[idx]=tmp;
			}
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void addX(int[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
	static void addX(long[]in,int x) {
		for(int i=0;i<in.length;i++)in[i]+=x;
	}
}