import random

t = int(input())
for _ in range(t):
  n, m = map(int, input().split())
  u = []
  v = []
  for i in range(m):
    x, y = map(int, input().split())
    u.append(x)
    v.append(y)
  p = [i for i in range(1, n + 1)]
  while True:
    random.shuffle(p)
    pos = [0] * (n + 1)
    for i in range(n):
      pos[p[i]] = i
    k = 0
    for i in range(m):
      if pos[u[i]] < pos[v[i]]:
        k += 1
    if 2 * k >= m:
      break
  print(' '.join(map(str, p)))
