#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)

struct DSU
{
    int n,x;
    vi p,r,sz;
    DSU(int N){
        n=N;x=N-1;sz.assign(N,1);p.assign(N,0);r.assign(N,1);
        for(int i=0;i<N;i++)p[i]=i;
    }
int find(int i){return (p[i]==i)?i:(p[i]=find(p[i]));}
bool sameset(int i,int j){return find(i)==find(j);}
void join(int i,int j)
{
    int p1=find(i);int p2=find(j);
    if(p1!=p2){
        x--;
        if(r[p1]>=r[p2]){
            p[p2]=p1;
            sz[p1]+=sz[p2];
            if(r[p1]==r[p2])
                r[p1]++;
        }
        else{
            p[p1]=p2;
            sz[p2]+=sz[p1];
        }
    }
}
void debug(){for(int it:p)cout<<it<<' ';cout<<endl;}
int getsize(int i){return sz[find(i)];}
int noOfSets(){return x;}
};

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
  }
  first = false;
  res += to_string(v[i]);
}
res += "}";
return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
}
return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
  }
  first = false;
  res += to_string(x);
}
res += "}";
return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,k;
    cin>>t;
    while(t--){
        cin>>n>>m;
        vvi adj(n);
        vii edges;
        for(int i=0;i<m;i++){
            cin>>x>>y;
            x--,y--;
            adj[x].pb(y);
            adj[y].pb(x);
            edges.pb(mp(x,y));
        }
        DSU d(n);
        for(int i=0;i<m;i++){
            d.join(edges[i].F,edges[i].S);
        }
        if(d.noOfSets()){
            cout<<"NO\n";
        }
        else{
            set<ll> boo;
            queue<ll> q;
            q.push(0);
            vector<bool> done(n,false);
            vi col(n,-1);
            boo.insert(0);
            while(boo.size()){
                ll v = *boo.begin();
                done[v] = true;
                boo.erase(boo.begin());
                col[v] = 0;
                for(auto it:adj[v]){
                    if(!done[it]){
                        col[it] = 1;
                        done[it] = true;
                        boo.erase(it);
                        for(auto nex:adj[it]){
                            if(!done[nex]){
                                boo.insert(nex);
                            }
                        }
                    }
                }
            }
            int cnt=0;
            for(int i=0;i<n;i++){
                if(!col[i])cnt++;
            }
            cout<<"YES\n";
            cout<<cnt<<endl;
            for(int i=0;i<n;i++){
                if(col[i]==0){
                    cout<<i+1<<" ";
                }
            }
            cout<<endl;
        }
    }
    return 0;
}   