//#pragma comment(linker, "/STACK:102400000,102400000")
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <limits>
#include <climits>
#include <cstdio>
#include <complex>
#include <numeric>
#include <cassert>
#include <bitset>
#include <chrono>
#include <random>
#include <unordered_set>
#define endl '\n'
#define mp(x,y) make_pair((x),(y))
#define PI pair<int,int>
#define PD pair<double,double>
#define PDI pair<double,int>
#define ll long long
#define ull unsigned long long
#define Fori(x) for(int i=0;i<(x);i++)
#define Forj(x) for(int j=0;j<(x);j++)
#define Fork(x) for(int k=0;k<(x);k++)
#define For1i(x) for(int i=1;i<=(x);i++)
#define For1j(x) for(int j=1;j<=(x);j++)
#define NXT(x,y) (((x)+1)%(y))
#define y1 asdfeawf
using namespace std;
//const int INF = 2147483647;
const int mod = 1000000007;
const int mod2 = 998244353;
const double eps = 1e-9;
const double pi = acos(-1.0);
inline int rint() { int x; scanf("%d", &x); return x; }
inline long long rll() { long long x; scanf("%lld", &x); return x; }
inline long long ri64() { long long x; scanf("%I64d", &x); return x; }
void rvi(vector<int> &a, int n) { for (int i = 0; i < n; i++) { a.push_back(rint()); } }
void rvll(vector<long long> &a, int n) { for (int i = 0; i < n; i++) { a.push_back(rll()); } }
void showvi(vector<int> &a) { for (int i = 0; i < a.size(); i++) { printf("%d%c", a[i], (i + 1 == a.size() ? '\n' : ' ')); } }
void showvll(vector<long long> &a) { for (int i = 0; i < a.size(); i++) { printf("%lld%c", a[i], (i + 1 == a.size() ? '\n' : ' ')); } }
void showviln(vector<int> &a) { for (int i = 0; i < a.size(); i++) { printf("%d%c", a[i], '\n'); } }
void showvllln(vector<long long> &a) { for (int i = 0; i < a.size(); i++) { printf("%lld%c", a[i], '\n'); } }
void showi(int x) { printf("%d", x); }
void cfinit() { ios::sync_with_stdio(false); cin.tie(0); }
ll pw(ll a, ll b, ll c) {ll ans = 1; ll k = a % c; while(b>0){if(b % 2 == 1) ans = (ans * k) % c; b = b/2; k = (k * k) % c;} return ans;}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll mysqrt(ll n) { ll x = sqrt(1.0*n); while (x*x < n) x++; while (x*x > n) x--; return x; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {return (ull)rng() % B;}
ll myRand(ll l,ll r){ return myRand(r-l+1)+l;}
bool gangpener = 1;

struct Union
{
public:
	Union(int n) { for (int i = 0; i <= n; i++) anc.push_back(i), cnt.push_back(1); }
	int find(int x) { /* be careful of stack overflow */ if (anc[x] == x) return x; anc[x] = find(anc[x]); return anc[x]; }
	void connect(int x, int y) { if (isConnected(x, y)) return; int t = count(x); anc[find(x)] = find(y); cnt[find(y)] += t; }
	bool isConnected(int x, int y) { return find(x) == find(y); }
	int count(int x) { return cnt[find(x)]; }
protected:
	vector<int> anc;
	vector<int> cnt;
};

int n,m;
vector<int> v[300033];

queue<int> que;
int vis[300033];
void solve()
{
	cin>>n>>m;
	Fori(n+5) vis[i] = 0;
	Union uni(n+10);
	Fori(m)
	{
		int l,r;
		cin>>l>>r;
		v[l].push_back(r);
		v[r].push_back(l);
		uni.connect(l,r);
	}
	if(uni.count(1)!=n)
	{
		Fori(n+5) v[i].clear();
		cout<<"NO"<<endl;
		return;
	}
	while(!que.empty()) que.pop();
	que.push(1);
	vis[1] = 1;
	int sum = 0;
	while(!que.empty())
	{
		int fk = que.front();
		que.pop();
		vis[fk] = 2;
		Fori(v[fk].size())
		{
			if(vis[v[fk][i]]==2) vis[fk] = 3;
		}
		if(vis[fk]==2) sum++;
		Fori(v[fk].size())
		{
			if(vis[v[fk][i]]!=0) continue;
			vis[v[fk][i]] = 1;
			que.push(v[fk][i]);
		}
	}
	cout<<"YES"<<endl;
	cout<<sum<<endl;
	For1i(n) if(vis[i]==2) cout<<i<<" ";
	cout<<endl;
	Fori(n+5) v[i].clear();
}

int main()
{
	cfinit();
	int T = 1;
	if(gangpener) cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}