#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    int n;
    std::deque<string> words;
    std::multimap<string, int> map;
    std::map<string, int> seen;
    while (cin>>s) {
        if (cin.fail()) {
            break;
        } else {
            cin>>n;
        }
        if (seen[s]==0) {
            words.emplace_back(s);
            seen[s]++;
        }
        map.insert(make_pair(s,n));
    }
    sort(words.begin(),words.end());
    for (int i=0;i<words.size();i++) {
        cout<<words[i]<<endl;
        std::deque<int> tmp;
        auto p=map.equal_range(words[i]);
        for (auto itr=p.first;itr!=p.second;itr++) {
            tmp.emplace_back(itr->second);
        }
        sort(tmp.begin(),tmp.end());
        for (int i=0;i<tmp.size();i++) {
            cout<<tmp[i];
            if (i!=tmp.size()-1) {
                cout<<" ";
            } else {
                cout<<endl;
            }
        }
    }
}
