#include<bits/stdc++.h>
using namespace std;
string s;
map<char,int>a;
int maxn;
int main()
{
for(int i=1;i<=4;i++)
{
getline(cin,s);
for(int j=0;j<s.length();j++)
{
a[s[j]]++;
maxn=max(maxn,a[s[j]]);
}
}
for(int i=maxn;i>=1;i--)
{
for(char j='A';j<='Z';j++)
{
if(a[j]>=i)
{
cout<<"* ";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
for(char i='A';i<='Z';i++)
{
cout<<i<<" ";
}
cout<<endl;
return 0;
}