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

int main() {
    map<string, set<int> > pagenumbers;

    string word;
    int page;

    while (cin >> word >> page) {
        pagenumbers[word].insert(page);
    }

    for (map<string, set<int> >::iterator it = pagenumbers.begin(); it != pagenumbers.end(); ++it) {
        cout << it->first << endl;
        for (set<int>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) {
            cout << *it2 << " ";
        }
        cout << endl;
    }

    return 0;
}