/*
TASK:sms
LANG:C++
*/

#include<iostream>
#include<map>
using namespace std;

map<string, int> msg;
map<string, int>::iterator msgi;
string msgs[128][12];
int main()
{
    int n;
    cin>>n;
    string s, ms;
    char s1[50], ms1[50];
    int count=1, nm, i, j, k;
    gets(s1);
    for(i=0; i<n; i++)
    {
        gets(s1);
        s=s1;
        cin>>nm;
        gets(ms1);
        gets(ms1);
        ms=ms1;
        if(msg[s]) k=msg[s];
        else
        {
            k=count;
            msg[s]=count++;
        }
        msgs[k][nm]=ms;
    }
    msgi=msg.begin();
    cout<<msgi->first<<endl;
    i=msgi->second;
    j=1;
    while(msgs[i][j]!="")cout<<msgs[i][j++]<<endl;
    msgi++;
    for(; msgi != msg.end(); msgi++)
    {
        printf("\n");
        cout<<msgi->first<<endl;
        i=msgi->second;
        j=1;
        while(msgs[i][j]!="")cout<<msgs[i][j++]<<endl;
    }
    /*
    for(i=0; i<n; i++)
        for(j=0; j<10; j++)
            cout<<i<<' '<<j<<' '<<msgs[i][j]<<endl;
    */
    return 0;
}
