#include <bits/stdc++.h>

using namespace std;

int main(void) {
    string s;
    int p;
    map<string, set<int> > mp;

    while (cin >> s >> p)
        mp[s].insert(p);
    
    for (map<string, set<int> >::iterator itm = mp.begin(); itm != mp.end(); itm++) {
        int flag = 0;
        cout << (*itm).first << '\n';
        for (set<int>::iterator its = (*itm).second.begin(); its != (*itm).second.end(); its++) {
            if (flag) printf(" ");
            printf("%d", (*its));
            flag = 1;
        }
        printf("\n");
    }

    return 0;
}
