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

#define int long long

vector<vector<int>> adj;
vector<bool> vis,incl;

void dfs(int u){
	vis[u]=true;
	bool ok=true;
	for(int v:adj[u]){
		if(incl[v])ok=false;
	}
	if(ok)incl[u]=true;
	for(int v:adj[u]){
		if(!vis[v])dfs(v);
	}
}

void solve(){
	int n,m;cin>>n>>m;
	adj.assign(n,vector<int>());
	vis.assign(n,false);
	incl.assign(n,false);
	while(m--){
		int u,v;cin>>u>>v;
		u--;v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(0);
	if(count(vis.begin(),vis.end(),false)){
		cout<<"NO\n";
		return;
	}
	vector<int> ans;
	for(int i=0;i<n;i++){
		if(incl[i])ans.push_back(i);
	}
	cout<<"YES\n";
	cout<<ans.size()<<"\n";
	for(int i=0;i<(int)ans.size();i++){
		cout<<ans[i]+1<<" \n"[i==(int)ans.size()-1];
	}
}

signed main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int t;cin>>t;
	while(t--){
		solve();
	}	
}
