#include<iostream>
#include<fstream>
#include<string>

using namespace std;

main()
{

	ifstream fin;
	ofstream fout;

	string Word;

	fin.open("DATA2.txt", ifstream::in);
	fout.open("OUT2.txt", ifstream::out);

	for(int i = 1; i <= 5; i++)
	{
		fin >> Word;

        char W[Word.length()];

        for(int j = 0; j < Word.length(); j++)
        {
			W[j] = char(Word[j]);
        }

		do
		{
			for(int j = 0; j < Word.length(); j++)
			{
				fout << W[j];
			}
			fout << "\n";
		}
		while(next_permutation(W, W + Word.length()));

	}

	fin.close();

	return 0;

}

