#include<iostream>
#include<vector>
#include<sstream>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include <list>
#include<cstdio>
#include<cstring>
using namespace std;
map<char, int>mymap;
vector<string>myv;
int arr[27];
int n = 4;
int main()
{
string s;
string temp;
while (n--)
{
getline(cin, temp);
s.append(temp);
}
for (int i = 0; i < s.size(); i++)
{
if (s[i] >= 'A' && s[i] <= 'Z')
{
mymap[s[i]]++;
}
}
char c = 'A';
for (int i = 0; i < 26; i++)
{
arr[i] = mymap[c++];
}
int maxsize = 0;
for (int i = 0; i < 26; i++)
{
maxsize = max(maxsize, arr[i]);
}
string ans;
for (int i = 0; i < maxsize; i++)
{
for (int j = 25; j >=0; j--)
{
if (j == 25 && arr[j] != 0)
{
ans += "*";
arr[j]--;
}
else if (arr[j] != 0)
{
ans += " *";
arr[j]--;
}
else
{
ans += " ";
}
}
ans += '\n';
}
reverse(ans.begin(), ans.end());
cout << ans << endl;
c = 'A';
for (int i = 0; i < 26; i++)
{
if (i == 25)
{
cout << c++;
break;
}
cout << c++ << " ";
}
return 0;
}