#include<bits/stdc++.h>
using namespace std;
int bit, n, a[90], len, maxnl, maxn, t;
string str;
char yy;
int main() {
for (int i = 1; i <= 4; i++) {
getline(cin, str);
getchar();
len = str.size();
for (int j = 0; j < len; j++) {
a[str[j] - 'A']++;
t = max(t, a[str[j] - 'A']);
}
}
for (int i = t; i >= 1; i--) {
for (int j = 0; j < 25; j++)
if (a[j] == i)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;
}