
// Problem : D. Strange Housing
// Contest : Codeforces - Codeforces Round #694 (Div. 1)
// URL : https://codeforces.com/problemset/problem/1470/D
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define w(x)  int x; cin>>x; while(x--)
using namespace std;
const long long N=100005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
vi prime;
bool isprime[N];
void pre()
{
    for(int i=2;i<N;i++)
    {
        if(isprime[i])
        {
            for(int j=i*i;j<N;j+=i)
            isprime[j]=false;
            prime.pb(i);
        }
    }
    return;
}
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

int spf[N+1];
void spfFun(){
    for(int i=0;i<=N;i++) spf[i]=i;
    for(int i=2;i*i<=N;i++){
        if(spf[i]==i){
            for(int j=i*i;j<=N;j+=i){
                spf[j] = min(spf[j],i);
            }
        }
    }
}

bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
}
void print(bool n){
    if(n){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
}

vector<int> par,height,vis;
vector<vector<int>> g;

void dsu_init(int n){
    par.resize(n+1);
    height.resize(n+1);
    for(int i=0;i<n;i++){
        par[i]=i;
    }
}

int dsu_find(int u){
    if(par[u]==u){
        return u;
    }                                 
    return par[u] = dsu_find(par[u]); 
}                                     

void dsu_merge(int a,int b){
    a = dsu_find(a);                  
    b = dsu_find(b);
    if(a==b) return;                  
    if(height[a]<height[b]) swap(a,b);    
    par[b]=a;                        
    if(height[b]==height[a]) height[a]++;   
}

void dfs(int u){
	vis[u]=1;
	for(int i:g[u]){
		if(vis[i]) continue;
		dfs(i);
	}
}

vector<int> ans,te;
queue<int>q;

void mark(int u){
	ans.pb(u);
	te[u]=1;
	dsu_merge(0,u);
	for(auto i:g[u]){
		te[i]=1;
		if(dsu_find(i)!=dsu_find(0)){
			q.push(i);
			dsu_merge(0,i);
		}
	}
}


int32_t main()
{
    IOS;
    // pre();
    // fill(isprime,true);
    w(t){
    	int n,m;
    	cin>>n>>m;
    	g.clear();
    	par.clear();
    	height.clear();
    	vis.clear();
    	ans.clear();
    	while(!q.empty()) q.pop();
    	te.clear();
    	te.resize(n);
    	vis.assign(n,0);
    	g.resize(n);
    	for(int i=0;i<m;i++){
    		int u,v;
    		cin>>u>>v;
    		--u,--v;
    		g[u].pb(v);
    		g[v].pb(u);
    	}
    	dfs(0);
    	int flag=1;
    	for(int i=0;i<n;i++){
    		if(!vis[i]){
    			flag=0;
    			break;
    		}
    	}
    	if(!flag){
    		print(flag);
    		cout<<"\n";
    		continue;
    	}
    	
    	dsu_init(n);
    	mark(0);
    	while(!q.empty()){
    		int x = q.front();
    		q.pop();
    		for(auto i:g[x]){
    			if(te[i]==0){
    				mark(i);
    			}
    		}
    	}
    	for(int i=0;i<n;i++){
    		if(dsu_find(i)!=dsu_find(0)){
    			flag=0;
    			// cout<<i<<" ";
    			break;
    		}
    	}
    	if(!flag){
    		print(flag);
    		cout<<"\n";
    		continue;
    	}
    	print(flag);
    	cout<<"\n";
    	cout<<ans.size()<<"\n";
    	sort(all(ans));
    	for(auto i:ans) cout<<i+1<<" ";
    	cout<<"\n";
    }
}