#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t;
    cin >> t;
    
    while (t--) {
        int n, m;
        cin >> n >> m;
        
        // Topological sort using Kahn's algorithm
        // Goal: find lexicographically smallest valid ordering of tasks
        
        // adj[i] stores all tasks that come after task i
        vector<vector<int>> adj(n + 1);
        
        // deg[i] = incoming edges (how many tasks must be done before task i)
        vector<int> deg(n + 1, 0);
        
        // Build the directed graph
        for (int i = 0; i < m; i++) {
            int a, b;
            cin >> a >> b;  // a must come before b
            adj[a].push_back(b);
            deg[b]++;
        }
        
        // Min heap - always pick smallest numbered task available
        // This ensures lexicographically smallest ordering
        priority_queue<int, vector<int>, greater<int>> pq;
        
        // Start with tasks that have no dependencies (in-degree = 0)
        for (int i = 1; i <= n; i++) {
            if (deg[i] == 0) {
                pq.push(i);
            }
        }
        
        vector<int> ans;
        
        // Process tasks in topological order
        while (!pq.empty()) {
            int curr = pq.top();
            pq.pop();
            ans.push_back(curr);
            
            // Remove this task from graph
            // Check if any dependent tasks are now ready
            for (int next : adj[curr]) {
                deg[next]--;
                if (deg[next] == 0) {
                    pq.push(next);
                }
            }
        }
        
        // If we couldn't process all tasks, there's a cycle
        if (ans.size() != n) {
            cout << -1 << "\n";
        } else {
            for (int i = 0; i < n; i++) {
                if (i > 0) cout << " ";
                cout << ans[i];
            }
            cout << "\n";
        }
    }
    
    return 0;
}