#include
<
iostream
>
using namespace std;
void Permulate( char s[], int start, int all);
void Copy( char a[], char b[], int i);
int main()
{
char s[10];
cin>>s;
int temp=0;
while(s[temp]) temp++;
Permulate(s,0,temp);
return 0;
}
void Copy( char a[], char b[], int i)
{
for(int m=0;m<i;m++)
b[m]=a[m];
}
void Permulate( char s[], int start, int all)
{
int temp=0;
if(start==all-1)
{
cout<<s[0];
for(temp=1;temp<all;temp++) cout<<' '<<s[temp];
cout<<endl;
return;
}
char a[10];
for(temp=start;temp<all;temp++)
{
char chr=s[temp];s[temp]=s[start];s[start]=chr;
Copy(s,a,all);
Permulate(a,start+1,all);
}
}
using namespace std;
void Permulate( char s[], int start, int all);
void Copy( char a[], char b[], int i);
int main()
{
char s[10];
cin>>s;
int temp=0;
while(s[temp]) temp++;
Permulate(s,0,temp);
return 0;
}
void Copy( char a[], char b[], int i)
{
for(int m=0;m<i;m++)
b[m]=a[m];
}
void Permulate( char s[], int start, int all)
{
int temp=0;
if(start==all-1)
{
cout<<s[0];
for(temp=1;temp<all;temp++) cout<<' '<<s[temp];
cout<<endl;
return;
}
char a[10];
for(temp=start;temp<all;temp++)
{
char chr=s[temp];s[temp]=s[start];s[start]=chr;
Copy(s,a,all);
Permulate(a,start+1,all);
}
}