import java.io.*;
import java.util.*;

public class two 
{
	
	public static void main(String[] args) throws IOException
	{
		BufferedReader bf = new BufferedReader(new FileReader("DATA2.txt"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("OUT2.txt")));
		
		for(int a = 0; a < 5; a++)
		{
			String perm = bf.readLine();
			int initSize = perm.length();
			
			for (int i = perm.length() - 1; i <= 5; i++)
				perm += " ";
			
			List<String> perms = new ArrayList<String>();
			
			int size = perm.length();
			
			for(int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					if (j == i)
						continue;
					for(int k = 0; k < size; k++)
					{
						if (k == j || k == i)
							continue;
						for (int l = 0; l < size; l++)
						{
							if (l == k || l == i || l == j)
								continue;
							for(int o = 0; o < size; o++)
							{
								if (o == l || o == k || o == j || o == i)
									continue;
								String answer = perm.charAt(i) + "" + perm.charAt(j) + "" + perm.charAt(k) + "" + perm.charAt(l) + "" + perm.charAt(o);
								String newAnswer = "";
								for (int h = 0; h < answer.length(); h++)
									if (answer.charAt(h) != ' ')
										newAnswer += answer.charAt(h);
								
								boolean allIn = false;
								for (int h = 0; h < perms.size(); h++)
								{
									if (perms.get(h).equals(newAnswer))
										allIn = true;
								}
								
								if (newAnswer.length() >= initSize && !allIn)
									perms.add(newAnswer);
							}
						}
					}
				}
			}
			
			for (int i = 0; i < perms.size(); i++)
				out.println(perms.get(i));
			
		}
		
		out.close();
		System.exit(0);
	}

}

