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 MainClass
{
    static StringBuilder stringBuilder = new StringBuilder();
    static Set<Integer> h = new HashSet<>();
    static DSU DSU;
    static Map<Integer, Integer> map = new HashMap<>();
    static Map<Integer, Integer> invMap = new HashMap<>();
    public static void main(String[] args)throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        int m = in.nextInt();
        int d = in.nextInt();
        ArrayList<Integer>[] adj = new ArrayList[n];
        for (int i=0;i<n;i++)   adj[i] = new ArrayList<>();
        for (int i=0;i<m;i++)
        {
            int x = in.nextInt() - 1;
            int y = in.nextInt() - 1;
            adj[x].add(y);
            adj[y].add(x);
        }
        for (int u: adj[0]) h.add(u);
        int len = adj[0].size();
        DSU = new DSU(len);
        for (int i=0;i<len;i++) DSU.makeSet(i);
        int counter = 0;
        for (int u: adj[0])
        {
            map.put(u, counter);
            invMap.put(counter++, u);
        }
        boolean[] visited = new boolean[n];
        visited[0] = true;
        for (int u: adj[0])
        {
            if (!visited[u])
            {
                explore(adj, u, visited, u);
            }
        }
        Set<Integer> cc = new HashSet<>();
        for (int i=0;i<len;i++) cc.add(DSU.findSet(i));
        if (cc.size() > d || adj[0].size() < d)
            System.out.println("NO\n");
        else
        {
            stringBuilder.append("YES\n");
            int extra = d - cc.size();
            visited = new boolean[n];
            visited[0] = true;
            Set<Integer> partial = new HashSet<>();
            for (int u: cc)
            {
                int orig = invMap.get(u);
                stringBuilder.append(1).append(" ").append(orig + 1).append("\n");
                partial.add(orig);
            }
            for (int u: adj[0])
            {
                if (extra <= 0)
                    break;
                if (!cc.contains(map.get(u)))
                {
                    stringBuilder.append(1).append(" ").append(u + 1).append("\n");
                    extra--;
                    partial.add(u);
                }
            }
            for (int u: cc) recur(adj, invMap.get(u), visited, partial);
            System.out.println(stringBuilder);
        }
    }
    public static void recur(ArrayList<Integer>[] adj, int v, boolean[] visited, Set<Integer> partial)
    {
        visited[v] = true;
        for (int u: adj[v])
        {
            if (!visited[u])
            {
                if (!partial.contains(u))
                    stringBuilder.append(v + 1).append(" ").append(u + 1).append("\n");
                recur(adj, u, visited, partial);
            }
        }
    }
    public static void explore(ArrayList<Integer>[] adj, int v, boolean[] visited, int par)
    {
        visited[v] = true;
        if (h.contains(v) && v != par) DSU.unionSets(map.get(par), map.get(v));
        for (int u: adj[v])
        {
            if (!visited[u])
            {
                explore(adj, u, visited, par);
            }
        }
    }
}
class DSU
{
    int[] parent;
    int[] size;
    //Pass number of total nodes as parameter to the constructor
    DSU(int n)
    {
        this.parent = new int[n];
        this.size = new int[n];
        Arrays.fill(parent, -1);
    }

    public void makeSet(int v)
    {
        parent[v] = v;
        size[v] = 1;
    }

    public int findSet(int v)
    {
        if (v == parent[v]) return v;
        return parent[v] = findSet(parent[v]);
    }

    public void unionSets(int a, int b)
    {
        a = findSet(a);
        b = findSet(b);
        if (a != b)
        {
            if (size[a] < size[b])
            {
                int temp = a;
                a = b;
                b = temp;
            }
            parent[b] = a;
            size[a] += size[b];
        }
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private final DataInputStream din;
    private final byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}