/**
 *    author:  tourist
 *    created: 08.11.2024 19:07:08
**/
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    int n, m;
    cin >> n >> m;
    int k = 0;
    for (int i = 0; i < m; i++) {
      int u, v;
      cin >> u >> v;
      k += int(u < v);
    }
    if (2 * k >= m) {
      for (int i = 0; i < n; i++) {
        cout << i + 1 << " \n"[i == n - 1];
      }
    } else {
      for (int i = 0; i < n; i++) {
        cout << n - i << " \n"[i == n - 1];
      }
    }
  }
  return 0;
}
