python代码
from itertools import permutations n = int(input()) s = [i for i in range(1,n+1)] for p in permutations(s,n): print(' '.join(map(str,p)))