from itertools import permutations#引入套件
try:#讀取多冊資
while 1:
a=int(input())
aa=list(range(1,a+1))
aa.sort(reverse=True)
for i in permutations(aa,a):#使用套件瓊舉
print("".join(tuple(map(str,i))))
except:
pass
#套件使用說明:https://docs.python.org/zh-cn/3/library/itertools.html