#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define sd second
using namespace std;
const int N=2e5+5;
inline int read(){
int x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x=x*10+ch-48,ch=getchar();}
return x*f;
}
int T,n,m,tot,in[N];
set<int> e[N];
set<pii,greater<pii > > s;
bool flg;
int vis[N],idx,siz,mx;
void dfs(int u){
vis[u]=idx,siz++;
for(int v:e[u]){
if(vis[v]!=idx){
dfs(v);
if(siz-1>mx) return;
}
}
}
void dfs2(int u){
vis[u]=idx;
for(int v:e[u])
if(vis[v]!=idx)
dfs2(v);
}
int id[N];
vector<int> ans[N];
int fa[N],sz[N],U[N],V[N],In[N];
inline int Find(int x){
return x==fa[x]?x:fa[x]=Find(fa[x]);
}
map<int,int> mp;
map<pair<int,int> ,bool> lk;
inline void merge(int x,int y){
x=Find(x),y=Find(y);
if(x==y) return;
fa[x]=y,sz[y]+=sz[x];
}
signed main(){
T=read();
while(T--){
n=read(),m=read(),flg=0;
for(int u,v,i=1;i<=m;i++){
u=read(),v=read();
e[u].insert(v);
e[v].insert(u);
U[i]=u,V[i]=v;
in[u]++,in[v]++;
}
idx=1,tot=0,s.clear();
for(int i=1;i<=n;i++) s.insert({in[i],i});
while(!s.empty()){
int u=(*s.begin()).sd;
s.erase(s.begin());
for(int v:e[u]){
s.erase({in[v],v});
in[v]--;
s.insert({in[v],v});
e[v].erase(u);
}
for(int v:e[u])
ans[u].emplace_back(v);
id[++tot]=u;
}
lk.clear();
for(int i=1;i<=n;i++) fa[i]=i,sz[i]=1;
for(int i=tot;i;i--){
int f=id[i];
mp.clear();
vector<int> real;
int sum=0;
for(int x:ans[f]){
lk[{x,f}]=1;
if(!mp[Find(x)]) mp[Find(x)]=1,real.emplace_back(x),sum+=sz[Find(x)];
}
if(sum!=in[f]){
flg=1;
break;
}
ans[f]=real;
for(int x:ans[f]) merge(x,f);
}
if(lk.size()!=m) flg=1;
if(!flg){
for(int i=1;i<=m;i++){
if(!lk[{U[i],V[i]}]&&!lk[{V[i],U[i]}]){
flg=1;
break;
}
}
}
if(flg){
puts("No");
for(int i=1;i<=n;i++) vis[i]=0,in[i]=0,e[i].clear(),ans[i].clear();
continue;
}
puts("Yes");
for(int i=tot;i;i--){
int f=id[i];
printf("%d ",f);
printf("%d ",(int)ans[f].size());
for(int x:ans[f]) printf("%d ",x);
puts("");
}
for(int i=1;i<=n;i++) vis[i]=0,in[i]=0,e[i].clear(),ans[i].clear();
}
return 0;
}