#include <iostream>
#include <cstdio>
using namespace std ;
// 输出全排列
const int MAX = 1000;
int a[MAX];
int n ;
int book[MAX];
void dfs(int step)
{
int i ;
if(step==n+1)
{
for(i=1;i<=n;i++)
cout<<a[i];
cout<<endl;
return ;
}
for(i=1;i<=n;i++)
{
if(book[i]==0)
{
book[i] = 1 ;
a[step]= i ;
dfs(step+1);
book[i] = 0;
}
}
return ;
}
int main()
{
cin>>n ;
dfs(1);
getchar() ;
return 0;
}