#include<bits/stdc++.h>
using namespace std;
int a,d[100100],mi;
string s1;
int main()
{
for(int i=1;i<=4;i++)
{
getline(cin,s1);
for(int j=0;j<s1.size();j++)
if(s1[i]>='A'&&s1[i]<='Z') d[int(s1[j])]++;
}
for(int i=int('A');i<=int('Z');i++)
mi=max(d[i],mi);
for(int i=mi;i>=1;i--)
{
for(int j=int('A');j<=int('Z');j++)
{
if(d[j]==i)
{
cout<<"* ";
d[j]--;
}
else cout<<" ";
}
cout<<endl;
}
cout<<"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z";
return 0;
}