#include<bits/stdc++.h>
using namespace std;
int main(){
map<char,int> mp;
for(char i='A';i<='Z';i++){
mp[i]=0;
}
for(int i=0;i<4;i++){
string str;
getline(cin,str);
int len = str.length();
for(int i=0;i<len;i++){
if(str[i]>='A' && str[i]<='Z'){
mp[str[i]]++;
}
}
}
int max_row = 0;
char mout[400][26];
for(char i='A';i<='Z';i++){
int column = i - 'A';
int row = mp[i];
if(row > max_row) max_row = row;
for(int j=row-1;j>=0;j--){
mout[j][column] = '*';
}
}
for(int i=max_row-1;i>=0;i--){
for(int j=0;j<25;j++){
cout<<mout[i][j]<<" ";
}
cout<<mout[i][25]<<endl;
}
for(char i='A';i<'Z';i++){
cout<<i<<" ";
}
cout<<"Z"<<endl;
return 0;
}