#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    pair<string,int> index[1000];
    int cnt;
    for(cnt=0;cin>>index[cnt].first>>index[cnt].second;cnt++);
    sort(index,index+cnt);
    cout << index[0].first << endl << index[0].second;
    rep(i,cnt){
        if(i == 0) continue;
        if(index[i].first == index[i-1].first) cout << " " << index[i].second;
        else cout << endl << index[i].first << endl << index[i].second;
    }
    cout << endl;
    return 0;
}
