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 javax.imageio.ImageTranscoder;
import java.io.*;
import java.util.*;

public class f {
    static class Graph{
        static class Pair implements Comparable<Pair>{
            int a;
            int b;
            int c;
            Pair(int a,int b,int c){
                this.a = a;
                this.b = b;
                this.c = c;
            }

            @Override
            public int hashCode() {
                return 23*a+b*7+c+13;
            }

            @Override
            public boolean equals(Object obj) {
                if(this == (Pair) obj){
                    return true;
                }
                return false;
            }

            @Override
            public int compareTo(Pair o) {
                if(this.c<o.c){
                    return 1;
                }
                return -1;
            }
        }

        int vertices;
        ArrayList<Integer> edge[];
        //static ArrayList<Pair> list;
        static ArrayList<Integer> count;
        static Set<Integer> set;
        //static int count;
        static int[] degree;
        static boolean[] visited;
        static int[][] st;
        static int max = 0;
        static int z;
        static Map<Integer,Integer> parent;
        Graph(int vertices){
            set = new HashSet<>();
            this.vertices = vertices;
            edge = new ArrayList[vertices+1];
            for(int i=0;i<=vertices;i++){
                edge[i] = new ArrayList<>();
            }
            parent = new HashMap<>();
            count = new ArrayList<>();
            //list = new ArrayList<>();
            degree = new int[vertices+1];
        }
        void addEdge(int a,int b){
            edge[a].add(b);
            edge[b].add(a);
        }
        void DFS(){
            visited = new boolean[vertices+1];
            DFSutil(1,visited);

        }
        void DFSutil(int v,boolean[] visited){
            visited[v] = true;
            Iterator<Integer> iterator = edge[v].listIterator();
            while (iterator.hasNext()){
                int n = iterator.next();
                if(!visited[n]){
                    parent.put(n,v);
                    //list.add(new Pair(v,n,0));
                    if(v==1){
                        count.add(n);
                        set.add(n);
                    }
                    DFSutil(n,visited);
                }
            }

        }
//        void DFSs(){
//            if(z<=max) {
//                ArrayList<Pair> list = new ArrayList<>();
//                Stack<Integer> stack = new Stack<>();
//                boolean[] visited = new boolean[vertices + 1];
//                stack.add(1);
//                visited[1] = true;
//
//
//                while (stack.size() > 0) {
//                    int v = stack.pop();
//                    Iterator<Integer> iterator = edge[v].listIterator();
//                    while (iterator.hasNext()){
//                        int n = iterator.next();
//                        if(!visited[n]){
//                            stack.add(n);
//                            visited[n] = true;
//                            list.add(new Pair(v,n,0));
//                            if(v==1){
//                            }
//                        }
//                    }
//                }
//
//                System.out.println(count);
//
//                for (int i = 0; i < list.size(); i++) {
//                    System.out.println(list.get(i).a + " " + list.get(i).b);
//                }
//            }
//            else{
//                System.out.println("NO");
//            }
//        }

        static void solve()throws IOException{
            BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
            String[] s1 = inp.readLine().split(" ");
            int v = Integer.parseInt(s1[0]);
            int e = Integer.parseInt(s1[1]);
            z = Integer.parseInt(s1[2]);
            Graph graph = new Graph(v);
            st = new int[e][2];
            int m = 0;
            for(int i=0;i<e;i++){
                String[] s2 = inp.readLine().split(" ");
                int a = Integer.parseInt(s2[0]);
                int b = Integer.parseInt(s2[1]);
                graph.addEdge(a,b);
                degree[a]++;
                degree[b]++;
                st[i][0] = a;
                st[i][1] = b;
                m = Math.max(degree[a],m);
                if(m==degree[a]){
                    max = a;
                }
                m = Math.max(degree[b],m);
                if(m==degree[b]){
                    max = b;
                }
            }
            graph.DFS();
            if(z<=degree[1]){
                if(count.size()<=z){
                    System.out.println("YES");
                    //System.out.println(count);
                    int less = z-count.size();
                    Iterator<Integer> iterator = graph.edge[1].listIterator();
                    while (less>0 && iterator.hasNext()){
                        int n = iterator.next();
                        //System.out.println(n);
                        if(!set.contains(n)){
                            less--;
                            count.add(n);
                            set.add(n);
                            //System.out.println(count);
                        }
                    }
                    for(int i=0;i<count.size();i++){
                        parent.put(count.get(i),1);
                    }
                    BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
                    for(int i=2;i<=v;i++){
                        int a = i;
                        int b = parent.get(i);
                        out.write(a+" "+b+"\n");
                    }
                    out.flush();
                }
                else{
                    System.out.println("NO");
                }
            }
            else{
                System.out.println("NO");
            }
        }
    }

    public static void main(String[] args) throws IOException {
        Graph.solve();
    }
}