#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

struct Book{
    string s;
    vector<int> page;
};

int main(){
    string s;
    int p, i = 0;
    struct Book book[105];
    while(cin >> s >> p){
        bool c = true;
        rep(j,i){
            if(book[j].s == s){
                book[j].page.push_back(p);
                c = false;
            }
        }
        if(c){
            book[i].s = s;
            book[i].page.push_back(p);
            i++;
        }
    }
    rep(j,i){
        rep(k,i){
            if(book[k].s < book[k + 1].s){
                struct Book g = book[k];
                book[k] = book[k + 1];
                book[k + 1] = g;
            }
        }
    }
    rep(j,i){
        debug(book[j].s)
        sort(book[j].page.begin(), book[j].page.end());
    }
    for(int j = i; j >= 0; j--){
        cout << book[j].s << endl;
        rep(k, book[j].page.size()){
            if(k) cout << ' ';
            cout << book[j].page[k];
        }
        cout << endl;
    }
}