n,m = map(int,input().split()) for i in range(m): a,b = map(int,input().split()) x = list(i for i in range(1,n+1) if i not in [a,b]) print(* ([a,b] + x)) print(*(x[::-1] + [a,b]))