/*
Zenit CK 2011/2012, uloha d)
Riesenie by Zemco
Formatovac a vykreslovac tabuliek futbalovych strelcov.
Predpoklady: padol aspon jeden gol, nikto nedal viac ako 999 golov.
*/
#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<sstream>
using namespace std;
typedef vector<string> VS;
typedef map<int,VS> int2VS;
//mapa: strelec -> pocet golov
map<string,int> M;
//mapa: pocet golov -> zoznam strelcov
int2VS S;
//sirky stlpcov
int stlpce[3];
//vypis vodorovnu oddelujucu ciaru
void outline(){
cout << "+" << string(stlpce[0]+2,'-') << "+" << string(stlpce[1]+2,'-') << "+" << string(stlpce[2]+2,'-') << "+" << endl;
}
//vrati pocet znakov, ktore zabera cislo
int dlzkazapisu(int cislo){
ostringstream os;
os << cislo;
return os.str().length();
}
int main(){
//nacitame strelcov, zistime rozne hodnoty strelenych golov a pre kazdu, kto vsetko ich nastrielal
string s;
while(cin >> s) M[s]++;
for(map<string,int>::iterator it = M.begin(); it != M.end(); it++){
S[(*it).second].push_back( (*it).first );
}
//vyhodime tych, co nejsu dost dobri aby sa dostali do tabulky :)
int miest = min(10,(int)S.size());
while(S.size() > 10) S.erase(S.begin());
//zistime si sirky stlpcov
stlpce[0] = miest == 10 ? 3 : 2;
stlpce[1] = 0;
for(int2VS::iterator it = S.begin(); it != S.end(); it++){
for(int i=0;i<(int)(*it).second.size(); i++) stlpce[1] = max(stlpce[1],(int)(*it).second[i].length());
}
stlpce[2] = 1;
int2VS::iterator itt = S.end(); itt--;
stlpce[2] = dlzkazapisu( (*itt).first );
//pre kazdu hodnotu vypiseme tych, ktori ju dosiahli
outline();
int umiestnenie = 1;
for( int2VS::reverse_iterator it = S.rbegin(); it != S.rend(); it++){
for(int j=0;j<(int)(*it).second.size();j++){
if ( j == 0 ){
cout << "| " << umiestnenie << ". ";
if (miest == 10 && umiestnenie!=10) cout << " ";
}
else cout << "|" << string(stlpce[0]+2,' ');
cout << "| " << (*it).second[j] << string(stlpce[1]+1-(*it).second[j].length(),' ') << "| ";
if ( j == 0 ) cout << (*it).first << string(stlpce[2] - dlzkazapisu((*it).first),' ');
else cout << string(stlpce[2],' ');
cout << " |" << endl;
}
outline();
umiestnenie++;
}
return 0;
}