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:
        for i in range(1, n + 1):
            if i > 1:
                print(' ', end='')
            print(i, end='')
        print()
    else:
        for i in range(n, 0, -1):
            if i < n:
                print(' ', end='')
            print(i, end='')
        print()

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