#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <map>
#include <functional>
#include <set>
using namespace std;
//1120
char ch[8],ans[8];
int len,visit[8];
void fuck(int k){
if(k==len){
ans[k]='\0';
printf("%s\n",ans);
return ;
}
for(int i=0;i<len;i++){
if(!visit[i]){
visit[i]=1;
ans[k]=ch[i];
fuck(k+1);
visit[i]=0;//回溯
}
}
}
int main()
{
while(cin>>ch){
len=strlen(ch);
for(int i=0;i<len;i++)
visit[i]=0;
fuck(0);
puts("");
}
return 0;
}
/**************************************************************
Problem: 1120
User: cust123
Language: C++
Result: Accepted
Time:480 ms
Memory:1520 kb
****************************************************************/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
char str[7];
while(scanf("%s", str) != EOF){
int len = strlen(str);
do{
printf("%s\n", str);
}while(next_permutation(str, str + len)); //把str字符串排列组合 然后放回str字符串
printf("\n");
}
return 0;
}
/**************************************************************
Problem: 1120
User: cust123
Language: C++
Result: Accepted
Time:330 ms
Memory:1020 kb
****************************************************************/