from itertools import permutations n = int(input()) arr = [i+1 for i in range(n)] for i in permutations(arr,n): print(" ".join(map(str,i)))