#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
// MLE
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector<set<int>> adj(n);
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
adj[i].insert(j);
}
}
for (int i = 0; i < m; i++) {
int a, b;
cin >> a >> b;
--a, --b;
adj[a].erase(b);
}
// Topology sort
vector<int> in_degree(n, 0);
for (int i = 0; i < n; i++) {
for (int child : adj[i]) {
in_degree[child]++;
}
}
priority_queue<int> q;
for (int i = 0; i < n; i++) {
if (in_degree[i] == 0) q.push(i);
}
int cnt = 0;
vector<int> ans;
while (!q.empty()) {
int x = q.top();
q.pop();
ans.push_back(x + 1);
for (int child : adj[x]) {
if (--in_degree[child] == 0) q.push(child);
}
cnt++;
}
if (cnt != n) assert(false);
for (int i = 0; i < sz(ans); i++) {
cout << ans[i] << " \n"[i == sz(ans) - 1];
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIGFsbChjKSAoYykuYmVnaW4oKSwgKGMpLmVuZCgpCiNkZWZpbmUgc3ooeCkgKGludCkoeCkuc2l6ZSgpCgovLyBNTEUKaW50IG1haW4oKSB7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CiAgICBpbnQgdDsKICAgIGNpbiA+PiB0OwogICAgd2hpbGUgKHQtLSkgewogICAgICAgIGludCBuLCBtOwogICAgICAgIGNpbiA+PiBuID4+IG07CiAgICAgICAgdmVjdG9yPHNldDxpbnQ+PiBhZGoobik7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuIC0gMTsgaSsrKSB7CiAgICAgICAgICAgIGZvciAoaW50IGogPSBpICsgMTsgaiA8IG47IGorKykgewogICAgICAgICAgICAgICAgYWRqW2ldLmluc2VydChqKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG07IGkrKykgewogICAgICAgICAgICBpbnQgYSwgYjsKICAgICAgICAgICAgY2luID4+IGEgPj4gYjsKICAgICAgICAgICAgLS1hLCAtLWI7CiAgICAgICAgICAgIGFkalthXS5lcmFzZShiKTsKICAgICAgICB9CgogICAgICAgIC8vIFRvcG9sb2d5IHNvcnQKICAgICAgICB2ZWN0b3I8aW50PiBpbl9kZWdyZWUobiwgMCk7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICAgICAgZm9yIChpbnQgY2hpbGQgOiBhZGpbaV0pIHsKICAgICAgICAgICAgICAgIGluX2RlZ3JlZVtjaGlsZF0rKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBwcmlvcml0eV9xdWV1ZTxpbnQ+IHE7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICAgICAgaWYgKGluX2RlZ3JlZVtpXSA9PSAwKSBxLnB1c2goaSk7CiAgICAgICAgfQogICAgICAgIGludCBjbnQgPSAwOwogICAgICAgIHZlY3RvcjxpbnQ+IGFuczsKICAgICAgICB3aGlsZSAoIXEuZW1wdHkoKSkgewogICAgICAgICAgICBpbnQgeCA9IHEudG9wKCk7CiAgICAgICAgICAgIHEucG9wKCk7CiAgICAgICAgICAgIGFucy5wdXNoX2JhY2soeCArIDEpOwogICAgICAgICAgICBmb3IgKGludCBjaGlsZCA6IGFkalt4XSkgewogICAgICAgICAgICAgICAgaWYgKC0taW5fZGVncmVlW2NoaWxkXSA9PSAwKSBxLnB1c2goY2hpbGQpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNudCsrOwogICAgICAgIH0KICAgICAgICBpZiAoY250ICE9IG4pIGFzc2VydChmYWxzZSk7CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBzeihhbnMpOyBpKyspIHsKICAgICAgICAgICAgY291dCA8PCBhbnNbaV0gPDwgIiBcbiJbaSA9PSBzeihhbnMpIC0gMV07CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0KCg==