import java.io.;
import java.util.;
//java的二进制优化
public class Main{
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
List[HTML_REMOVED] list=new ArrayList<>();
dfs(n,list,0,0);
}
public static void dfs(int n,List[HTML_REMOVED] list,int end,int mask){
if(end==n){
for(int res:list){
System.out.print(res+” “);
}
System.out.println();
return;
}
for(int i=1;i<=n;i++){
//剪枝
if((mask>>(i-1)&1)==1) continue;
int tmp=mask;
//施工
mask=mask|1<<(i-1);
list.add(i);
dfs(n,list,end+1,mask);
//恢复现场
list.remove(list.size()-1);
mask=tmp;
}
}
}