#include <bits/stdc++.h>

int main(){
    std::map<std::string, std::vector<int> > ind;
    while (true){
        std::string s;
        int n;
        std::cin>>s>>n;
        if(std::cin.fail())break;
        ind[s].push_back(n);
    }
    for (auto &i : ind) {
        std::cout<< i.first<<std::endl;
        std::sort(i.second.begin(),i.second.end());
        for (size_t j = 0; j < i.second.size()-1; ++j) {
            std::cout<< i.second[j]<<" ";
        }
        std::cout<< i.second[i.second.size()-1]<<std::endl;
    }
    return 0;
}
