#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
char s[10],src[10];
int n;
cin>>s;
n=strlen(s);
sort(s,s+n);
strcpy_s(src,s);
cout<<s<<endl;
while(next_permutation(s,s+n))
{
if (strcmp(s,src)==0)
break;
else cout<<s<<endl;
}
return 0;
}