import java.util.Scanner;
public class Main {
private static Scanner cin;
public static void main(String args[]) throws Exception {
cin = new Scanner(System.in);
int maxChar = 0;
int[] count = new int[26];
String line = null;
char[] character = null;
for(int i=0;i<4;i++) {
line = cin.nextLine();
character = line.toCharArray();
for(char c : character) {
if(32 == c) {
//space
continue;
}else if(c>=65 & c<= 90) {
count[c-65] += 1;
if(count[c-65]>maxChar) {
maxChar = count[c-65];
}
}
}
}
char[][] outChar = new char[26][maxChar];
for(int i = 0;i<26;i++) {
for(int j = 0; j<maxChar;j++) {
if(j<count[i]) {
outChar[i][j]='*';
}else {
outChar[i][j] = ' ';
}
}
}
for(int j=maxChar-1;j>=0;j--) {
for(int i=0;i<26;i++) {
if(i<25) {
System.out.print(outChar[i][j]+" ");
}else {
System.out.print(outChar[i][j]);
}
}
System.out.println();
}
for(int i=0;i<26;i++) {
if(i<25) {
System.out.print((char)(65+i)+" ");
}else {
System.out.print((char)(65+i));
}
}
System.out.println();
}
}