import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=0;
int[] word=new int[72];
int[] space=new int[72];
while(sc.hasNext()) {
String str=sc.nextLine();
n++;
for(int i=0;i<str.length();i++) {
if((str.charAt(i)-'A')>=0&&(str.charAt(i)-'A')<='Z'-'A')
word[str.charAt(i)-'A']++;
}
if(n==4) {
n=0;
int m=max(word);
for(int i=0;i<=('Z'-'A');i++) {
space[i]=m-word[i];
}
while(m>0) {
char []a=new char[72];
int index=0;
for(int i=0;i<=2*('Z'-'A');i++)
a[i]=' ';
for(int i=0,k=0;i<=('Z'-'A');i++,k+=2) {
if(word[i]>0&&space[i]==0) {
a[k]='*';
a[k+1]=' ';
index=k;
}
if(space[i]>0) {
space[i]--;
}
}
for(int i=0;i<index+1;i++) {
System.out.print(a[i]);
if(i==index)
System.out.print("\r\n");
}
m--;
}
for(int i=0;i<=('Z'-'A');i++) {
System.out.print((char)(65+ i));
if(i<('Z'-'A'))
System.out.print(' ');
}
System.out.println();
for(int i=0;i<=('Z'-'A');i++) {
space[i]=0;
word[i]=0;
}
}
}
sc.close();
}
public static int max(int[] a) {
int m=0;
for(int i=0;i<a.length;i++) {
if(m<=a[i])
m=a[i];
}
return m;
}
}