visit = [0] * 10
def dfs(cur, max_step, path):
if cur == max_step:
print(' '.join(path))
return
for val in range(1, max_step+1):
if visit[val] == 0:
visit[val] = 1
path.append(str(val))
dfs(cur+1, max_step, path)
path.pop(-1)
visit[val] = 0
dfs(0, int(input()), [])