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 A 
{
    public static void main(String[] args) throws IOException {
        input.init(System.in);
        PrintWriter out = new PrintWriter(System.out);
       
        int n = input.nextInt(), m = input.nextInt(),D=input.nextInt();
        char[] types = new char[6*m+5];
        int[] as = new int[6*m+5], bs = new int[6*m+5];
        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 u=input.nextInt()-1,v=input.nextInt()-1;
        	adj[u].add(v);
        	adj[v].add(u);
        	as[i]=u;
        	bs[i]=v;
        	types[i]='+';
        }
        int idx=m;
        for(int u=0;u<n;u++) {
        	for(int v:adj[u]) {
        		types[idx]='-';
        		as[idx]=u;
        		bs[idx]=v;
        		idx++;
        	}
        	types[idx++]='?';
        	for(int v:adj[u]) {
        		types[idx]='+';
        		as[idx]=u;
        		bs[idx]=v;
        		idx++;
        	}
        }
        
        
        m=idx;
        int ans=-1;
        DynamicConnectivity dc = new DynamicConnectivity(n, m, types, as, bs);
        ArrayList<Integer> res = dc.count();
        for(int i=0;i<=0;i++) {
        	
        	if(adj[i].size()<D)
        		continue;
        	
        	int cc=res.get(i);
        	int edges=cc-1;
        	if(edges<=D) {
        		ans=i;
        		break;
        	}
        }
       
        if(ans==-1) {
        	System.out.println("NO");
        	return;
        }
       
        DSU dsu=new DSU(n);
        for(int i=0;i<n;i++)
        	for(int v:adj[i])
        		if(i!=ans && v!=ans)
        			dsu.union(i, v);
        int x=0;
        boolean []taken=new boolean[adj[ans].size()];
        res.clear();
        for(int i=0;i<taken.length && x<D;i++) {
        	int v=adj[ans].get(i);
        	if(dsu.union(ans, v))
        	{
        		res.add(ans);
        		res.add(v);
        		taken[i]=true;
        		x++;
        	}
        }
        for(int i=0;i<taken.length && x<D;i++) {
        	int v=adj[ans].get(i);
        	if(!taken[i])
        	{
        		res.add(ans);
        		res.add(v);
        		taken[i]=true;
        		x++;
        	}
        }
        dsu=new DSU(n);
        for(int i=0;i<res.size();i+=2) {
        	int u=res.get(i),v=res.get(i+1);
        	dsu.union(u, v);
        }
        for(int u=0;u<n;u++)
        	for(int v:adj[u])
        		if(u!=ans && v!=ans && dsu.union(u,v))
        		{
        			res.add(u);
        			res.add(v);
        		}
        out.println("YES");
        for(int i=0;i<res.size();i+=2) {
        	int u=res.get(i)+1,v=res.get(i+1)+1;
        	out.println(u+" "+v);
        }
        out.close();
    }
    static class DSU
	{
		int []p,r;
		DSU(int n){
			p=new int [n];
			r=new int [n];
			for(int i=0;i<n;i++)
				p[i]=i;
		}
		boolean union(int i,int j) {
			int x=findSet(i);
			int y=findSet(j);
			if(x==y)
				return false;
			if(r[x]>r[y]) {
				p[y]=x;
			}
			else
			{
				p[x]=y;
				if(r[x]==r[y])
					r[y]++;
			}
			return true;
			
		}
		int findSet(int x) {
			if(p[x]==x)
				return x;
			else
				return p[x]=findSet(p[x]);
		}
	}
    static class DynamicConnectivity
    {
        int[] cnt, ans, color, deg, u;
        int n, k;
        ArrayList<Integer>[] g;
        DynamicConnectivity(int n, int k, char[] types, int[] as, int[] bs)
        {
            this.n = n;
            this.k = k;
            HashMap<Long, Integer> m = new HashMap<Long, Integer>();
            ArrayList<Edge> v = new ArrayList<Edge>();
            g = new ArrayList[n];
            for(int i = 0; i<n; i++) g[i] = new ArrayList<Integer>();
            cnt = new int[k + 1];
            ans = new int[k+1];
            color = new int[n];
            deg = new int[n];
            u = new int[n];
            for (int i = 0; i < k; i++) 
            {
                char type = types[i];
                if (type == '+' || type == '-') 
                {
                    int a = as[i], b = bs[i];
                    if (a == b)
                    {
                        k--;
                        i--;
                        continue;
                    }
                    if (a > b)
                    {
                        int temp = a;
                        a = b;
                        b = temp;
                    }
                    if (type == '+') 
                    {
                        m.put((long) n * a + b, i);
                    } 
                    else 
                    {
                        int j = m.get((long) n * a + b);
                        v.add(new Edge(a, b, j, i));
                        m.put((long) n * a + b, -1);
                    }
                } 
                else cnt[i + 1]++;
                cnt[i + 1] += cnt[i];
            }
            for (long x : m.keySet())
                if (m.get(x) != -1)
                    v.add(new Edge((int) (x / n), (int) (x % n), m.get(x), k));
            go(0, k, v, n, 0);
        }
        ArrayList<Integer> count()
        {
            ArrayList<Integer> res = new ArrayList<Integer>();
            for (int i = 0; i < k; i++)
                if (cnt[i + 1] != cnt[i])
                    res.add(ans[i]);
            return res;
        }
        void add(int a, int b) {
            g[a].add(b);
            g[b].add(a);
        }
        void dfs(int v, int value)
        {
            u[v] = 1;
            color[v] = value;
            for (int e : g[v])
                if (u[e] == 0)
                    dfs(e, value);
        }
        void go(int l, int r, ArrayList<Edge> v, int vn, int add_vn)
        {
            if (cnt[l] == cnt[r])
                return; // no queries, only changes
            if (v.size() == 0)
            {
                while (l < r)
                    ans[l++] = vn + add_vn;
                return;
            }
            ArrayList<Edge> v1 = new ArrayList<Edge>();
            for (int i = 0; i < vn; i++)
                g[i].clear();
            for (int i = 0; i < v.size(); i++)
            {
                Edge e = v.get(i).copy();
                if (e.a != e.b) {
                    if (e.l <= l && r <= e.r)
                        add(e.a, e.b);
                    else if (l < e.r && e.l < r)
                        v1.add(e);
                }
            }
            int vn1 = 0;
            for (int i = 0; i < vn; i++)
                u[i] = 0;
            for (int i = 0; i < vn; i++)
                if (u[i] == 0)
                {
                    deg[vn1] = 0;
                    dfs(i, vn1++);
                }
    
            for (int i = 0; i < v1.size(); i++)
            {
                Edge e = v1.get(i);
                e.a = color[e.a];
                e.b = color[e.b];
                if (e.a != e.b)
                {
                    deg[e.a]++;
                    deg[e.b]++;
                }
            }
            vn = vn1;
            vn1 = 0;
            for (int i = 0; i < vn; i++)
            {
                u[i] = vn1;
                vn1 += (deg[i] > 0) ? 1 : 0;
                add_vn += deg[i] > 0 ? 0 : 1;
            }
            for (int i = 0; i < v1.size(); i++)
            {
                Edge e = v1.get(i);
                e.a = u[e.a];
                e.b = u[e.b];
            }
    
            int m = (l + r) / 2;
            go(l, m, v1, vn1, add_vn);
            go(m, r, v1, vn1, add_vn);
        }
    }
    static class Edge
    {
        int a, b, l, r;
        public Edge(int aa, int bb, int ll, int rr)
        {
            a = aa;
            b = bb;
            l = ll;
            r = rr;
        }
        Edge copy()
        {
            return new Edge(a, b, l, r);
        }
    }
    public static class input {
        static BufferedReader reader;
        static StringTokenizer tokenizer;

        static void init(InputStream input) {
            reader = new BufferedReader(new InputStreamReader(input));
            tokenizer = new StringTokenizer("");
        }

        static String next() throws IOException {
            while (!tokenizer.hasMoreTokens())
                tokenizer = new StringTokenizer(reader.readLine());
            return tokenizer.nextToken();
        }

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

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

        static long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}