#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 300005;
int T, n, m, dep[maxn], ok[maxn], vis[maxn];
vector<int> out[maxn];
queue<int> Q;
int main() {
	scanf("%d", &T);
	while(T--) {
		scanf("%d%d", &n, &m);
		for(int i = 1; i <= n; i++) out[i].clear(), ok[i] = vis[i] = 0;
		for(int i = 1, x, y; i <= m; i++) {
			scanf("%d%d", &x, &y);
			out[x].push_back(y), out[y].push_back(x);
		}
		ok[1] = vis[1] = 1;
		Q.push(1);
		while(!Q.empty()) {
			int u = Q.front();
			Q.pop();
			ok[u] = 1;
			for(auto v : out[u]) 
				if(ok[v]) {
					ok[u] = 0;
					break;
				} 
			for(auto v : out[u]) 
				if(!vis[v]) vis[v] = 1, Q.push(v);
		}
		int ans = 0, flag = 0;
		for(int i = 1; i <= n; i++) {
			if(!vis[i]) flag = 1;
			ans += ok[i];
		}
		if(flag) puts("NO");
		else {
			puts("YES");
			printf("%d\n", ans);
			for(int i = 1; i <= n; i++) if(ok[i]) printf("%d ", i);
			puts("");
		}
	}
	return 0;
}