#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<algorithm>

using namespace std;

int main() {
    map<string, vector<int> > pages;
    string word;
    int page;

    while(cin>>word>>page) {
        pages[word].push_back(page);
    }

    for(auto& e : pages) {
        sort(e.second.begin(), e.second.end());
    }

    for(auto& e :pages) {
        cout<<e.first<<endl;
        for(auto& v: e.second) {
            cout<<v<<" ";
        }
    }
    
    return 0;
}