#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
char s[210];
int main()
{
while(~scanf("%s", s))
{
int n = strlen(s);
sort(s, s+n);
do
{
printf("%s\n", s);
}while(next_permutation(s, s+n));
}
return 0;
}
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;
char s[210];
int main()
{
while(~scanf("%s", s))
{
int n = strlen(s);
sort(s, s+n);
do
{
printf("%s\n", s);
}while(next_permutation(s, s+n));
}
return 0;
}