#include <bits/stdc++.h>
#define pii pair <int,int>
#define fi first
#define se second
#define ll long long
#define el cout<<'\n'
#define prob "1470D"
using namespace std;

const int N=3e5;
int n,m,d[N+1],ok=0;
vector <vector <int> >lk;
vector <int>res;

void bfs(int u,int color)
{
    queue <int> q;
    q.push(u);
    d[u]=color;
    while (q.size())
    {
        u=q.front();q.pop();
        for (int v:lk[u])
        {
            if (d[v]+d[u]==2 )
            {
                d[v]=-d[u];
                q.push(v);
                continue;
            }
            if (d[v]!=0) continue;
            d[v]=-d[u];q.push(v);
        }
    }
}

void input()
{
    cin>>n>>m;
    lk.clear();res.clear();
    for (int i=1;i<=n;i++) d[i]=0;
    lk.resize(n+1);
    for (int i=1;i<=m;i++)
    {
        int u,v;
        cin>>u>>v;
        lk[u].push_back(v);
        lk[v].push_back(u);
    }
    ok=0;
    bfs(1,1);
    for (int i=1;i<=n;i++)
    {
        if (d[i]==1) res.push_back(i);
        if (d[i]==0) {cout<<"NO\n";return;}
    }
    cout<<"YES\n";
    cout<<res.size();el;
    for (int v:res)
        cout<<v<<' ';
    el;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t;
    cin>>t;
    while (t--)
    input();
    return 0;
}

