#include<cstring>
#include<bits/stdc++.h>
using namespace std;
int main() {
int i,top=0;
char s[100];
int j,a[26]={0};
for (i = 0; i < 4; i++) {
gets_s(s);
for (j = 0; j < strlen(s); j++) {
if(s[j]>='A'&&a[j]<='Z')
a[s[j]-'A']++;
}
}
for (i = 0; i < 26; i++) {
if (top < a[i]) top = a[i];
}
char** pps8Output = (char**)malloc(top * sizeof(char*));
for (i = 0; i < top; i++)
{
pps8Output[i] = (char*)malloc(26 * sizeof(char));
}
for (i = 0; i < top; i++) {
for (j = 0; j < 26; j++) pps8Output[i][j] = ' ';
}
for (i = 0; i < 26; i++) {
for (j = 1; j <= a[i]; j++) {
pps8Output[top - j][i] = '*';
}
}
for (i = 0; i < top; i++) {
for (j = 0; j < 26; j++) printf("%c ", pps8Output[i][j]);
printf("\n");
}
for (i = 0; i < 26; i++) printf("%c ", 'A' + i);
}