def dfs(depth, n, num, st):
if depth == n:
for i in range(n):
print(f”{num[i]}”, end=’ ‘)
print()
return
for i in range(n):
if (st[i] == False):
num[depth] = i + 1
st[i] = True
dfs(depth + 1, n, num, st)
st[i] = False
def main():
n = int(input(“n=”))
num = [0]n
st = [False]n
dfs(0, n, num, st)
main()