def solve():
    n, m = map(int, input().split())
    edges = [tuple(map(int, input().split())) for _ in range(m)]
    if len([edge for edge in edges if edge[0] > edge[1]]) <= m // 2:
        print(*range(1, n + 1))
    else:
        print(*range(n, 0, -1))

for _ in range(int(input())):
    solve()