void dfs(int step);
int a[10], book[10], n;
int main(){
//1-9的整数
scanf("%d", &n);
//从第一个箱子开始。直接从下标1开始。0不要了。
dfs(1);
}
void dfs(int step){
int i;
//已经到最后一个箱子了。
if(step == n+1){
for(i=1; i<=n; i++){
printf("%d", a[i]);
}
printf("\n");
}
//在第step个箱子面前,按照1,2,3...n的顺序一一尝试
for(i=1; i<=n; i++){
//等于0就是i还没有使用,还在手里。
if(book[i] == 0){
//使用i
a[step] = i;
//标记i已经使用
book[i] = 1;
//前进一步
dfs(step + 1);
//回收step箱子里的牌
book[i] = 0;
}
}
}