#include <bits/stdc++.h>
using namespace std;
const int M=10005;
string s[5];
int c[105];
int main(){
for(int i=1; i<=4; i++)
getline(cin, s[i]);
for(int i=1; i<=4; i++){
for(int j=1; j<=s[i].size(); j++)
c[s[i][j]]++;
}
int maxx=-1;
for(int i=65; i<=90; i++)
maxx=max(maxx, c[i]);
for(int i=maxx; i>=0; i--){
if(i){
int n;
for(int j=65; j<=90; j++)
if(c[j]>=i) n=j;
for(int j=65; j<=90; j++){
if(c[j]>=i) cout<<"*";
else cout<<" ";
if(j==n) break;
if(j!=90) cout<<" ";
}
cout<<endl;
}
else{
for(int j=65; j<=90; j++){
cout<<(char)j;
if(j!=90) cout<<" ";
}
}
}
return 0;
}