#include<iostream>
using namespace std;
const int N = 10;
int n;
void dfs(int u,int nums[],bool state[]){
//如果当前的字符位数大于n,则当前排列已满,可输出
if(u>n){for(int i=1;i<=n;i++)cout<<nums[i]<<' ';cout<<endl;}
else{
for(int i=1;i<=n;i++){
if(!state[i]){
state[i]=true;
nums[u]=i;
dfs(u+1,nums,state);
state[i]=false;
}
}
}
}
int main(){
int nums[N];bool state[N]={0};
cin>>n;
dfs(1,nums,state);
}