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.BufferedOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Task {

    public static void solve() throws Exception {
	int n = nextInt();
	int m = nextInt();
	int d = nextInt();
	Map<Integer, Set<Integer>> map = new HashMap<>(n);
	for (int i = 1; i <= n; i++) {
	    map.put(i, new HashSet<Integer>());
	}
	for (int i = 0; i < m; i++) {
	    int a = nextInt();
	    int b = nextInt();
	    map.get(a).add(b);
	    map.get(b).add(a);
	}

	Set<Integer> firstSet = map.get(1);
	if (firstSet.size() < d) {
	    println("NO");
	    return;
	}

	Map<Integer, Integer> nr2group = new HashMap<>(firstSet.size());
	int group = 0;
	Set<Integer> visited = new HashSet<>(n);
	for (Integer start : firstSet) {
	    if (!visited.contains(start)) {
		go(start, visited, map, firstSet, nr2group, group);
		group++;
	    }
	}
	if (group > d) {
	    println("NO");
	    return;
	}

	Set<Integer> visitedGroups = new HashSet<>();
	Set<Integer> firstClone = new HashSet<>(firstSet.size());
	firstClone.addAll(firstSet);
	for (Integer node : firstClone) {
	    Integer g = nr2group.get(node);
	    if (!visitedGroups.contains(g)) {
		visitedGroups.add(g);
	    } else {
		if (firstSet.size() > d) {
		    firstSet.remove(node);
		    map.get(node).remove(1);
		}
	    }
	}

	println("YES");
	visited = new HashSet<Integer>();
	visited.add(1);
	List<Integer> list = new LinkedList<>();
	List<Integer> from = new LinkedList<>();
	for (Integer f : firstSet) {
	    list.add(f);
	    from.add(1);
	}
	while (!list.isEmpty()) {
	    Integer node = list.remove(0);
	    Integer orig = from.remove(0);
	    if (!visited.contains(node)) {
		visited.add(node);
		println(orig + " " + node);
		Set<Integer> set = map.get(node);
		for (Integer next : set) {
		    list.add(next);
		    from.add(node);
		}
	    }
	}
    }

    private static void go(Integer node, Set<Integer> visited, Map<Integer, Set<Integer>> map, Set<Integer> firstSet,
	    Map<Integer, Integer> nr2group, int group) {
	visited.add(node);
	if (firstSet.contains(node)) {
	    nr2group.put(node, group);
	}
	Set<Integer> set = map.get(node);
	for (Integer next : set) {
	    if (!visited.contains(next) && next.intValue() != 1) {
		go(next, visited, map, firstSet, nr2group, group);
	    }
	}
    }

    public static void main(String[] args) throws Exception {
	try {
	    fastReader = new FastReader(System.in);
	    systemOut = new BufferedOutputStream(System.out);
	    solve();
	} finally {
	    systemOut.close();
	}
    }

    private static FastReader fastReader = null;
    private static BufferedOutputStream systemOut = null;

    public static void print(Object obj) {
	print(obj.toString());
    }

    public static void print(String str) {
	try {
	    systemOut.write(str.getBytes("utf-8"));
	} catch (Exception ex) {
	    throw new RuntimeException(ex);
	}
    }

    public static void println(Object obj) {
	println(obj.toString());
    }

    public static void println(String str) {
	try {
	    print(str);
	    systemOut.write('\n');
	} catch (Exception ex) {
	    throw new RuntimeException(ex);
	}
    }

    public static String next() {
	return fastReader.readNextToken(false);
    }

    public static String nextLine() {
	return fastReader.readNextToken(true);
    }

    public static int nextInt() {
	return Integer.parseInt(fastReader.readNextToken(false));
    }

    public static long nextLong() {
	return Long.parseLong(fastReader.readNextToken(false));
    }

    public static double nextDouble() {
	return Double.parseDouble(fastReader.readNextToken(false));
    }

    static class FastReader {
	private byte[] buf = new byte[65536];
	private int ind = 0;
	private int maxInd = -1;
	private InputStream is = null;
	private boolean eof = false;
	private boolean lastCharRead = false;

	public FastReader(InputStream is) {
	    this.is = is;
	}

	public String readNextToken(boolean endOfLine) {
	    try {
		StringBuilder sb = new StringBuilder();
		boolean found = false;
		while (true) {
		    if (lastCharRead) {
			return null;
		    } else if (ind > maxInd) {
			if (eof) {
			    lastCharRead = true;
			} else {
			    fillBuffer();
			}
		    }
		    byte b = '\n';
		    if (!lastCharRead) {
			b = buf[ind++];
		    }

		    if (b == '\r') {
			// ignore
		    } else if ((b == '\n' && endOfLine) || (Character.isWhitespace(b) && !endOfLine)) {
			if (found) {
			    break;
			}
		    } else {
			sb.append((char) b);
			found = true;
		    }
		}
		return sb.toString();
	    } catch (Exception ex) {
		throw new RuntimeException(ex);
	    }
	}

	private void fillBuffer() {
	    try {
		int read = is.read(buf, 0, buf.length);
		if (read < buf.length) {
		    eof = true;
		}
		ind = 0;
		maxInd = read - 1;
	    } catch (Exception ex) {
		throw new RuntimeException(ex);
	    }
	}
    }
}