#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
vector<int> adj[300005];
int visited[300005];
void explore(int v)
 {if(visited[v]==1)
    {vector<int> z;
     for(auto x:adj[v])
       {if(visited[x]==-1){visited[x]=0;z.push_back(x);}
       }
     for(auto x:z)
        {explore(x);
        }
    return;
    }
  for(auto x:adj[v])
    {if(visited[x]==-1){visited[x]=1;explore(x);}
    }
 }
int32_t main()
{ios::sync_with_stdio(0);
 cin.tie(0);
 int t;
 cin>>t;
 while(t--)
    {int n,m;
     cin>>n>>m;int u,v;
     for(int i=0;i<n;i++){adj[i].clear();visited[i]=-1;}
     for(int i=0;i<m;i++)
        {cin>>u>>v;u--;v--;adj[u].push_back(v);adj[v].push_back(u);
        }
    explore(0);
    int poss=1;
    for(int i=0;i<n;i++){if(visited[i]==-1){poss=0;break;}}
    if(poss==0){cout<<"NO\n";}
    else
        {cout<<"YES\n";
         vector<int> ans;
         for(int i=0;i<n;i++)
            {if(visited[i]==1){ans.push_back(i+1);}
            }
         cout<<ans.size()<<"\n";
         for(auto x:ans){cout<<x<<" ";}cout<<"\n";
        }
    }
}
