#include<iostream>
#include<stdio.h>
#include<string.h>
#define max 110
int adj[max][max];
int status[max];
int n,e;
using namespace std;
void reset_adj_stat()
{
for(int i=1;i<=n;i++)
{
status[i]=0;
for(int j=1;j<=n;j++)
{
adj[i][j]=0;
}
}
}
void set(int s)
{
for(int i=1;i<=n;i++)
{
if((adj[s][i]==1)&&(status[i]==0))
{
status[i]=s;
}
}
}
void reset(int s)
{
for(int i=1;i<=n;i++)
{
if((adj[s][i]==1)&&(status[i]==s))
{
status[i]=0;
}
}
}
int check()
{
for(int i=1;i<=n;i++)
{
if(status[i]==0)
{
return 0;
}
}
return 1;
}
int get_optimal(int cnt,int &loc)
{
int m=0;
int c=check();
if(c)
return 0;
for(int i=1;i<=n;i++)
{
if(status[i]==0)
{
status[i]=i;
set(i);
int k=1+get_optimal(cnt+1,loc);
if(k>m)
{
m=k;
if(cnt==0)
{
loc=i;
}
}
status[i]=0;
reset(i);
}
}
return m;
}
void print_path(int &loc,int k)
{
for(int i=0;i<k;i++)
{
cout<<loc<<" ";
status[loc]=loc;
set(loc);
int cnt=0;loc=0;
int p=get_optimal(cnt,loc);
}
}
int main()
{
int t,v1,v2,cnt,loc,k;
cin>>t;
for(int i=0;i<t;i++)
{
cin>>n>>e;
reset_adj_stat();
cnt=0;
for(int j=1;j<=e;j++)
{
cin>>v1>>v2;
adj[v1][v2]=1;
adj[v2][v1]=1;
}
int k=get_optimal(cnt,loc);
if(k!=0)
{
cout<<k<<" "<<"\n";
print_path(loc,k);
cout<<"\n";
}
else
{
cout<<k<<" "<<"\n"<<"\n";
}
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0ZGlvLmg+CiNpbmNsdWRlPHN0cmluZy5oPgojZGVmaW5lIG1heCAxMTAKaW50IGFkalttYXhdW21heF07CmludCBzdGF0dXNbbWF4XTsKaW50IG4sZTsKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdm9pZCByZXNldF9hZGpfc3RhdCgpCnsKCWZvcih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