n=int(input());f=[1] for i in range(n):f+=f[-1]*-~i, def a(t): m=[0]*n;s=[*range(1,n+1)] for i in range(n):m[i]=s.pop(t//f[n-i-1]);t%=f[n-i-1] return m l,r=0,f[n];q=[0]*n while l+1>1)):l=m else:r=m print('!',*a(l))