#include<stdio.h>
#include<math.h>
# define N 101
char city[N][N],chengshi[N],kz[N];
int flag,m,count;
void fun(int row){
int i,j;
if(flag)
return ;
if(count>m ){
flag=1;
return ;
}
for(i=1;i<=m;i++){
if(kz[i] && city[row][i]){
chengshi[count++]=i;
kz[i]=0;
fun(i);
if(flag)
return;
else{
count--;
kz[i]=1;
}
}
}
}
int main()
{
int i,j,n,p,q;
scanf("%d",&n);
while(n--){
for(i=0;i<N;i++){
for(j=0;j<N;j++){
city[i][j]=0;
}
chengshi[i]=0;
kz[i]=1;
}
flag=0;
count=1;
scanf("%d",&m);
//如果只有一个城市,直接输出;
if(m==1){
printf("1\n");
continue;
}
//如果有两个以上个城市,用矩阵做;
for(i=1;i<=(m-1)*m/2;i++){
scanf("%d%d",&p,&q);
city[p][q]=1;
}
for(j=1;j<=m;j++){
chengshi[count++]=j;
kz[j]=0;
fun(j);
if(flag)
break;
else{
count--;
kz[j]=1;
}
}
for(i=1;i<=m;i++){
if(i==1)
printf("%d",chengshi[i]);
else
printf(" %d",chengshi[i]);
}
printf("\n");
}
return 0;
}
//直接搜