#include <bits/stdc++.h>
using namespace std;
#define en '\n'
#define ll long long
#define _bp __builtin_popcount
#define pb push_back
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define f first
#define s second
#define mp make_pair
void boos()
{
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int N = 3e5 + 100;
vector <int> g[N];
bool u[N];
bool ans[N];
void dfs(int v)
{
	u[v] = 1;
	for(int i = 0;i < g[v].size();i++)
	{
		int to = g[v][i];
		if(u[to])continue;
		if(ans[v])
		{
			ans[to] = 0;
		}
	}
	for(int i = 0;i < g[v].size();i++)
	{
		int to  =g[v][i];
		if(u[to])continue;
		dfs(to);
	}
}
int main()
{
	boos();
	int t;
	cin >> t;
	while(t--)
	{
		int n,m;
		cin >> n >> m;
		for(int i = 1;i <= n;i++)
		{
			g[i].clear();
			ans[i] = 1;
			u[i] = 0;
		}
		for(int i = 1;i <= m;i++)
		{
			int x,y;
			cin >> x >> y;
			g[x].pb(y);
			g[y].pb(x);
		}
		int kol = 0;
		for(int i = 1;i <= n;i++)
		{
			if(!u[i])
			{
				kol++;
				dfs(i);
			}
		}
		if(kol > 1)
		{
			cout << "NO" << en;
		}else {
			cout << "YES" << en;
			vector<int> q;
			for(int i = 1;i <= n;i++)
			{
				if(ans[i])q.pb(i);	
			}
			cout << q.size() << en;
			for(int i = 0;i < q.size();i++)
			{
				cout << q[i] << " ";
			}
			cout << en;
		}
	}
}