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.util.*;
import java.io.*;
 
public class Main {
    static int n,m,d;
    
    static ArrayList<Integer> adj[];
    static subsets[] subset;
    static boolean[] vis;
    
    void solve(PrintWriter out, Reader in) throws IOException{
        n = in.nextInt();
        m = in.nextInt();
        d = in.nextInt();
        
        vis = new boolean[n+1];
        adj = new ArrayList[n+1];
        for(int i=1;i<=n;i++)
            adj[i] = new ArrayList<Integer>();
        
        int u,v,cnt=0;
        for(int i=0;i<m;i++){
            u = in.nextInt();
            v = in.nextInt();
            
            if(u==1) {vis[v]=true;cnt++;}
            else if(v==1) {vis[u]=true;cnt++;}
            adj[u].add(v);
            adj[v].add(u);
        }
        
        if(cnt<d) {out.println("NO");return;}
        
        subset = new subsets[n+1];
        for(int i=1;i<=n;i++)
            subset[i] = new subsets(0,i);
        
        ArrayList<subsets> edges = new ArrayList<>();
        int s = n-1-d;
        
        loop:for(int i=2;i<=n;i++){
            if(s==0) break;
            for(int e:adj[i]){
                u = find(i);
                v = find(e);
                if(e!=1 && u!=v){
                    if(vis[u] && vis[v] && cnt==d) continue;
                    if(vis[u] && vis[v]) cnt--;
                    union(u,v);
                    if(vis[u]) vis[v] = true;
                    else if(vis[v]) vis[u] = true;
                    edges.add(new subsets(i,e));
                    s--;
                    if(s==0) break loop;
                }
            }
        }
        
        if(s==0){
            for(int e:adj[1]){
                if(find(e)!=find(1)){
                    union(e,1);
                    edges.add(new subsets(1,e));
                    s++;
                }
            }
        }else{
            out.println("NO");
            return;
        }
        if(s==d){
            out.println("YES");
            for(subsets e:edges)
                out.println(e.rank+" "+e.parent);
        }else out.println("NO");
    }
    
    //<>
    
    static class subsets {
        int rank,parent;
        
        subsets(int rank,int parent){
            this.rank = rank;
            this.parent = parent;
        }
    }
    
    static int find(int x){
        if(subset[x].parent!=x)
            subset[x].parent = find(subset[x].parent);
            
        return subset[x].parent;
    }
    
    static void union(int x,int y){
        int xroot = find(x);
        int yroot = find(y);
        
        if(xroot!=yroot){
            if(subset[xroot].rank<subset[yroot].rank){
                subset[xroot].parent = yroot;
            }else if(subset[xroot].rank>subset[yroot].rank){
                subset[yroot].parent = xroot;
            }else{
                subset[yroot].rank++;
                subset[xroot].parent = yroot;
            }
        }
        return;
    }
    
    
    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);
        Reader in = new Reader();
        Main solver = new Main();
        solver.solve(out, in);
        out.flush();
        out.close();
 
    }
    
    static class Reader {

    private InputStream mIs;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public Reader() {
        this(System.in);
    }

    public Reader(InputStream is) {
        mIs = is;
    }

    public int read() {
        if (numChars == -1) {
            throw new InputMismatchException();

    }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = mIs.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public String nextLine() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    public String next() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

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

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    }
}