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 F2 {
    static boolean[] visited;
    static List<Integer>[] adj;

    static void dfs(int u){
        visited[u] = true;
        for(int v : adj[u]){
            if(!visited[v]){
                dfs(v);
            }
        }
    }
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        int n, m, d;
        n = fs.nextInt(); m = fs.nextInt(); d = fs.nextInt();
        adj = new ArrayList[n + 1];
        DSU uf = new DSU(n + 1);
        List<Edge> edges = new ArrayList<Edge>();
        for(int i = 0; i < m; i++){
            int u, v;
            u = fs.nextInt(); v = fs.nextInt();
            if(adj[u] == null){
                adj[u] = new ArrayList<Integer>();
            }
            if(adj[v] == null){
                adj[v] = new ArrayList<Integer>();
            }
            adj[u].add(v);
            adj[v].add(u);
            Edge e = new Edge(u, v);
            edges.add(e);
        }
        visited = new boolean[n + 1];
        boolean bad = false;
        if(adj[1].size() < d){
            bad = true;
        }
        HashSet<Integer> need = new HashSet<>();
        visited[1] = true;
        for(int v : adj[1]){
            if(!visited[v]){
                //System.out.println("need " + v);
                dfs(v);
                need.add(v);
            }
        }  
        List<Edge> res = new ArrayList<>();
        if(need.size() > d){
            bad = true;
        } else {
            int rem = d - need.size();
            for(int v : need){
                res.add(new Edge(1, v));
                uf.merge(1, v);
            }
            //System.out.println("rem " + rem);
            //System.out.println(d);
            for(int v : adj[1]){
                if(rem > 0){
                    if(!need.contains(v)){
                        res.add(new Edge(1, v));
                        uf.merge(1, v);
                        rem--;
                    }
                } else {
                    break;
                }
            }
            for(Edge e : edges){
                int u = e.u; int v = e.v;
                if(u == 1 || v == 1){
                    continue;
                }
                if(uf.find(u) != uf.find(v)){
                    res.add(new Edge(u, v));
                    uf.merge(u, v);
                }
            }
        }
        if(bad){
            System.out.println("NO");
        } else {
            System.out.println("YES");
            for(Edge e : res){
                System.out.println(e.u + " " + e.v);
            }
        }
    }    
}

class Edge {
    int u, v;
    Edge(int u, int v){
        this.u = u;
        this.v = v;
    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    FastScanner(File f) {
        try {
            br = new BufferedReader(new FileReader(f));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

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

    String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

class DSU {
  private int[] adj;
  private int[] maxes;
  private int[] sizes;

  public DSU(int size){
    adj = new int[size];
    maxes = new int[size];
    sizes = new int[size];
    for(int idx = 0; idx < size; idx++){
      adj[idx] = maxes[idx] = idx;
      sizes[idx] = 1;
    }
  }

  public int find(int idx){
    while(adj[idx] != idx){
      idx = adj[idx];
    }
    return idx;
  }

  public int getSize(int idx){
    return sizes[find(idx)];
  }

  public int getMax(int idx){
    return maxes[find(idx)];
  }

  public void merge(int a, int b){
    int aHead = find(a);
    int bHead = find(b);
    if(aHead == bHead){
      return;
    }
    if(sizes[bHead] > sizes[aHead]){
      adj[aHead] = bHead;
      maxes[bHead] = Math.max(maxes[aHead], maxes[bHead]);
      sizes[bHead] += sizes[aHead];
    } else {
      adj[bHead] = aHead;
      maxes[aHead] = Math.max(maxes[aHead], maxes[bHead]);
      sizes[aHead] += sizes[bHead];
    }
  }

}