#include
#include
#include
#include<math.h>
#include
using namespace std;
string s;
map<char,int> mp;
int main()
{
int t = 4;
int maxx = 0;
while(t--){
s.erase(s.begin(),s.end());
getline(cin,s);
for(int i = 0;i<s.size();i++){
if(s[i]>='A'&&s[i]<='Z'){
mp[s[i]]++;
}
maxx = max(maxx,mp[s[i]]);
}
}
for(int i = maxx;i>=0;i--){
for(int j = 0;j<26;j++){
if(mp[j+'A']>=i){
cout<<"*";
}else{
cout<<" ";
}
if(j!=mp.size()){
cout<<' ';
}
}
cout<<endl;
}
map<char,int>::iterator it;
for(it = mp.begin();it!=mp.end();it++){
if(it->first >='A' &&it->first <='Z'){
cout<first;
cout<<' ';
}
}
return 0;
}