#include<iostream>
#include<fstream>
#include<algorithm>
#include<string>

using namespace std;

ifstream fin("DATA2.txt");
ofstream fout("OUT2.txt");

string s;
int main()
{
    for (int t = 0; t < 5; t++)
    {
        fin >> s;
        int aa[s.length()];
        for (int i = 0; i < s.length(); i++)
            aa[i] = i;
    
    do {
       for (int i = 0; i < s.length() - 1; i++)
       {
           fout << s[aa[i]];
       }
       fout << s[aa[s.length()-1]] << endl;
       } while ( next_permutation (aa, aa+s.length()) );

    }
    return 0;
}

