#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
set<ll> s[100001];
ll visited[1000001];
ll indegree[100001];
int main(){
boost;
ll T,N,i,j,k;
ll M;
cin >> T;
while(T--){
// v.clear();
cin >> N >> M;
memset(visited,0,sizeof(visited));
for(i = 0 ; i < N ; i++){
s[i].clear();
for(j = i+1 ; j < N ; j++){
s[i].insert(j);
indegree[j]++;
}
}
for(i = 0 ; i < M ; i++){
ll u,v;
cin >> u >> v;
u--;
v--;
s[min(u,v)].erase(s[min(u,v)].find(max(u,v)));
indegree[max(u,v)]--;
}
ll status = 0;
while(!status){
status = 1;
for(i = N-1 ; i >= 0 ; i--){
if(!visited[i] && indegree[i] == 0){
status = 0;
visited[i] = 1;
cout << i+1 << " ";
set<ll>::iterator it;
for(it = s[i].begin() ; it != s[i].end() ; it++)
indegree[*it]--;
break;
}
}
}
cout << endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCiNkZWZpbmUgYm9vc3QgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7Y2luLnRpZSgwKTtjb3V0LnRpZSgwKQoKdHlwZWRlZiBsb25nIGxvbmcgbGw7CgpzZXQ8bGw+IHNbMTAwMDAxXTsKbGwgdmlzaXRlZFsxMDAwMDAxXTsKbGwgaW5kZWdyZWVbMTAwMDAxXTsKCgppbnQgbWFpbigpewogICAgYm9vc3Q7CiAgICBsbCBULE4saSxqLGs7CiAgICBsbCBNOwogICAgY2luID4+IFQ7CiAgICB3aGlsZShULS0pewogICAvLyB2LmNsZWFyKCk7CiAgICBjaW4gPj4gTiA+PiBNOwogICAgbWVtc2V0KHZpc2l0ZWQsMCxzaXplb2YodmlzaXRlZCkpOwogICAgZm9yKGkgPSAwIDsgaSA8IE4gOyBpKyspewogICAgICAgIHNbaV0uY2xlYXIoKTsKICAgICAgICBmb3IoaiA9IGkrMSA7IGogPCBOIDsgaisrKXsKICAgICAgICAgICAgc1tpXS5pbnNlcnQoaik7CiAgICAgICAgICAgIGluZGVncmVlW2pdKys7CiAgICAgICAgfQogICAgfQoKICAgIGZvcihpID0gMCA7IGkgPCBNIDsgaSsrKXsKICAgICAgICBsbCB1LHY7CiAgICAgICAgY2luID4+IHUgPj4gdjsKICAgICAgICB1LS07CiAgICAgICAgdi0tOwogICAgICAgIHNbbWluKHUsdildLmVyYXNlKHNbbWluKHUsdildLmZpbmQobWF4KHUsdikpKTsKICAgICAgICBpbmRlZ3JlZVttYXgodSx2KV0tLTsKICAgIH0KICAgIGxsIHN0YXR1cyA9IDA7CiAgICB3aGlsZSghc3RhdHVzKXsKICAgICAgICBzdGF0dXMgPSAxOwogICAgICAgIGZvcihpID0gTi0xIDsgaSA+PSAwIDsgaS0tKXsKICAgICAgICAgICAgaWYoIXZpc2l0ZWRbaV0gJiYgaW5kZWdyZWVbaV0gPT0gMCl7CiAgICAgICAgICAgICAgICBzdGF0dXMgPSAwOwogICAgICAgICAgICAgICAgdmlzaXRlZFtpXSA9IDE7CiAgICAgICAgICAgICAgICBjb3V0IDw8IGkrMSA8PCAiICI7CiAgICAgICAgICAgICAgICBzZXQ8bGw+OjppdGVyYXRvciBpdDsKICAgICAgICAgICAgICAgIGZvcihpdCA9IHNbaV0uYmVnaW4oKSA7IGl0ICE9IHNbaV0uZW5kKCkgOyBpdCsrKQogICAgICAgICAgICAgICAgICAgIGluZGVncmVlWyppdF0tLTsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBlbmRsOwp9Cn0K