#include <bits/stdc++.h>
using namespace std;

const int N = 300010, M = 2 * N;
int n, m, idx, h[N], e[M], ne[M], colour[N];

inline void add(int a, int b) { e[idx] = b, ne[idx] = h[a], h[a] = idx++; }
inline void dfs(int u)
{
    int f = 0;
    for (int i = h[u]; i != -1; i = ne[i])
    {
        int v = e[i];
        if (colour[v] == 2)
            f = 1;
    }
    if (f)
        colour[u] = 1;
    else
        colour[u] = 2;
    for (int i = h[u]; i != -1; i = ne[i])
    {
        int v = e[i];
        if (colour[v])
            continue;
        dfs(v);
    }
}

int main()
{
    int t;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d%d", &n, &m);
        for (int i = 0; i <= n; i++)
            h[i] = -1, colour[i] = 0;
        while (m--)
        {
            int a, b;
            scanf("%d%d", &a, &b);
            add(a, b), add(b, a);
        }
        dfs(1);
        int cnt = 0;
        vector<int> res;
        for (int i = 1; i <= n; i++)
        {
            if (colour[i] == 2)
                res.push_back(i);
            if (colour[i])
                cnt++;
        }
        if (cnt < n)
            puts("NO");
        else
        {
            puts("YES");
            printf("%d\n", res.size());
            for (int i = 0; i < res.size(); i++)
                printf("%d ", res[i]);
            puts("");
        }
    }
    return 0;
}
			      	   	      	 					  	