’‘’
def dfs(u,n,used,state):
if(u>n):
print(‘ ‘.join(map(str,state[1:])))
for i in range(1,n+1):
if(used[i]==0):
state[u]=i
used[i]=True
dfs(u+1,n,used,state)
state[u]=0
used[i]=False
n=int(input())
state=[0 for i in range(n+1)]
used=[0 for i in range(n+1)]
dfs(1,n,used,state)
‘’‘