#include<bits/stdc++.h>
using namespace std;
int main(){
int a[26] = {0},max,len;
char z[400];
for(int i = 0;i < 4;i++){
gets(z);
len = strlen(z);
for(int i = 0;i < len;i++){
if(z[i] >= 'A'&&z[i] <= 'Z'){
a[z[i]-'A']++;
}
}
}
for(int i = 0; i < 26;i++) max = max > a[i]?max:a[i];
for(int i = max;i > 0;i--){
for(int j = 0;j < 26;j++){
if(a[j] >= i) cout<<"* ";
else cout<<" ";
}
cout<<endl;
}
cout<<"A B C D E F G H I G K L M N O P Q R S T U V W X Y Z"<<endl;
return 0;
}