#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
using namespace std;
priority_queue<int, vector<int>, greater<int> > pq[101];

int main()  {

    int t, idx = 0;
    char str[31];
    map<string, int> m;
    string stra;

    while(scanf("%s %d", str, &t) != EOF) {
        stra = str;
        if (stra == ".") break;
        if (m.find(stra) == m.end()) {
            m.insert({stra, idx});
            pq[idx++].push(t);
        } else {
            pq[m[stra]].push(t);
        }
    }

    for (map<string, int>::iterator it = m.begin(); it != m.end(); it++) {
        cout << it->first << endl;
        idx = 0;
        while (!pq[it->second].empty()) {
            if (idx) cout << " ";
            cout << pq[it->second].top(); pq[it->second].pop();
            idx++;
        }
        cout << endl;
    }


    return 0;
}

