import java.io.*;
import java.util.*;
public class q2 extends IOException
{
    private static List < String > array = new ArrayList < String > ();
    private static List < String > tempArray = new ArrayList < String > ();
    private static List < String > tempArray2 = new ArrayList < String > ();
    private static String tempString = "";



    public static void main (String[] args) throws IOException
    {
	BufferedReader fileIn = new BufferedReader (new FileReader ("DATA2.txt"));
	PrintWriter fileOut = new PrintWriter (new FileWriter ("OUT2.txt"));
	for (int i = 0 ; i < 5 ; i++)
	{
	    String temp = fileIn.readLine ();

	    for (int j = 0 ; j < temp.length () ; j++)
	    {
		array.add (j, "" + temp.charAt (j));
	    }

	    for (int j = 0 ; j < temp.length () ; j++)
	    {
		scramble (array.remove (j), j);
		

	    }

	    array.clear ();
	}
		try {
	for (String gayness : tempArray2) {
		fileOut.println (gayness);

	}		} catch (Exception e) {}
	fileOut.close ();
    }



    public static void scramble (String a, int index)
    {
	tempArray.add (a);
	if (array.size () == 0)
	{


		for (int i = 0 ; i < tempArray.size () ; i++)
		{
		    tempString += tempArray.get (i);
		}
		tempArray2.add (tempString);
tempString = "";
	}	



	//main recursion
	for (int i = 0 ; i < array.size () ; i++)
	{
	    scramble (array.remove (i), i);
	}


	tempArray.remove (a);
	array.add (index, a);
    }
}

