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 fixedDeg {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			int N = br.nextInt();
			int M = br.nextInt();
			int D = br.nextInt();
			LinkedList<Edge> edges = new LinkedList<Edge>();
			LinkedList<Integer>[] adj = new LinkedList[N];
			for(int i = 0; i < N; i++) {
				adj[i] = new LinkedList<Integer>();
			}
			boolean[] exists = new boolean[N];
			exists[0] = true;
			UnionFindSet u = new UnionFindSet(N);
			for(int i = 0; i < M; i++) {
				int x = br.nextInt();
				int y = br.nextInt();
				x--; y--;
				if(x == 0) {
					exists[y] = true;
					continue;
				}
				if(y == 0) {
					exists[x] = true;
					continue;
				}
				if(u.isSameSet(x, y)) {
					continue;
				}
				edges.add(new Edge(x,y,0));
				adj[y].add(x);
				adj[x].add(y);
				u.union(x, y);
			}
						
			Queue<Integer> q = new LinkedList<Integer>();
			boolean[] vis = new boolean[N];
			for(int i = 1; i < N; i++){
				if(exists[i]) {
					if(!u.isSameSet(0, i)) {
						u.union(0, i);
						edges.add(new Edge(0,i,-1));
						D--;
						if(D == 0) {
							break;
						}
						q.add(i);
					}
				}
			}
			boolean end = false;
			
			while(!q.isEmpty()) {
				int curr = q.poll();
				if(end) {
					break;
				}
				if(vis[curr]) {
					continue;
				}
				for(Integer e : adj[curr]) {
					if(D == 0) {
						break;
					}
					if(vis[e]) {
						continue;
					}
					if(exists[e]) {
						edges.add(new Edge(0,e,-1));
						if(!u.isSameSet(0, e)){
							u.union(0, e);
						}
						D--;
						if(D == 0) {
							end = true;
							break;
						}
					}
					q.add(e);
				}
				vis[curr] = true;
			}
			
			Collections.sort(edges);
			
			UnionFindSet mst = new UnionFindSet(N);
			if(D == 0) {
				if(u.sz(u.find(0)) == N) {
					pw.println("YES");
					for(Edge e : edges) {
						if(!mst.isSameSet(e.x, e.y)) {
							pw.println((e.x+1) + " " + (e.y+1));
							mst.union(e.x, e.y);
						}
					}
				}
				else {
					pw.println("NO");
				}
				
			}
			else {
				pw.println("NO");
			}
			
			
			
			pw.close();
		}
		public class UnionFindSet {
		    int n;
		    int[] parent;
		    int[] size;
		 
		    public UnionFindSet(int n) {
		        this.n = n;
		        parent = new int[n];
		        size = new int[n];
		        init();
		    }
		 
		    public void init(){
		        for (int i = 0; i < n; i++) {
		            parent[i] = i;
		            size[i] = 1;
		        }
		    }
		 
		    public int find(int id) {
		        if (parent[id] == id)
		            return id;
		        return parent[id] = find(parent[id]);
		    }
		 
		    public void union(int x, int y) {
		        int q = find(x);
		        int p = find(y);
		        if(q != p){
		            if(size[q] < size[p]){
		                int temp = q;
		                q = p;
		                p = temp;
		            }
		            parent[p] = q;
		            size[q] += size[p];
		            size[p] = 0;
		        }
		    }
		 
		    public int sz(int v) {
		    	return size[v];
		    }
		    
		    public boolean isSameSet(int x, int y) {
		        return find(x) == find(y);
		    }
		 
		}
		
		public static class Edge implements Comparable<Edge>{
			int x, y, w;
			public Edge(int x, int y, int w) {
				this.x = x;
				this.y = y;
				this.w = w;
			}
			@Override
			public int compareTo(Edge o) {
				// TODO Auto-generated method stub
				return this.w - o.w;
			}
		}
	}

	//fastscanner class
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}