这题点的个数(<=50)有限, 所以可以纯暴力DFS去搜索
//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x)))
#define MOD 1000000007
#define pi acos(-1.0) using namespace std; typedef long long ll ;
typedef unsigned long long ull ;
typedef unsigned int uint ;
typedef unsigned char uchar ; template<class T> inline void checkmin(T &a,T b){if(a>b) a=b;}
template<class T> inline void checkmax(T &a,T b){if(a<b) a=b;} const double eps = 1e- ;
const int N = ;
const int M = * ;
const ll P = 10000000097ll ;
const int MAXN = ; int n;
int g[][], vis[], ans[]; void init(){
memset(g, , sizeof(g));
} bool dfs(int pos, int level){
ans[level] = pos;
if(level >= n){
return true;
}
for(int i = ; i <= n; ++i){
if(i == pos) continue;
if(!vis[i] && g[pos][i]){
vis[i] = ;
if(dfs(i, level + )){
return true;
}
vis[i] = ;
}
}
} int main(){
std::ios::sync_with_stdio(false);
int i, j, t, k, u, v, numCase = ;
cin >> t;
while(t--){
init();
cin >> n;
for(i = ; i <= n * (n - ) / ; ++i){
cin >> u >> v;
g[u][v] = ;
}
for(i = ; i <= n; ++i){
memset(vis, , sizeof(vis));
memset(ans, , sizeof(ans));
vis[i] = ;
if(dfs(i, )) break;
vis[i] = ;
}
if(i != n + ){
for(i = ; i < n; ++i){
cout << ans[i] << ' ';
}
cout << ans[n] << endl;
} else{
cout << "Impossible" << endl;
}
} return ;
}