#include<bits/stdc++.h>
using namespace std;

static const int maxn=1e5+5;
char solve[maxn];

int main()
{
    while( ~scanf("%s",solve) )
    {
        int len=strlen(solve);
        do
        {
            //防止长得像cab这样的坑 
        }while( next_permutation(solve, solve+len));

        do
        {
            printf("%s\n",solve);
        } while( next_permutation(solve, solve+len));
    }


    return 0;
}