#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main() {
int nummber[26] = { 0 };
int max = 0;
char s1[50];
for (int i = 0; i < 4;i++) {
gets(s1);
for (int j = 0; j < strlen(s1); j++) {
if (s1[j] >= 'A'&&s1[j] <= 'Z')
nummber[s1[j] - 'A']++;
}
}
for (int i = 0; i < 26; i++) {
if (nummber[i] >= max)
max = nummber[i];
}
for (int i = max-1; i>=0 ; i--) {
for (int j =0; j <26; j++) {
if (i < nummber[j])
cout << "*";
else
cout << " ";
}
cout << endl;
}
for (int i = 0; i < 26; i++)
printf("%c", i + 'A');
}