#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define vi vector<int>
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a),end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

void sort(int x[102]){
    rep(i,102){
        rep(j,102){
            bool c = true;
            if(x[j] > x[j + 1]){
                int temp = x[j];
                x[j] = x[j + 1];
                x[j + 1] = temp;
                c = false;
            }
            if(c) break;
        }
    }
}

int main(){
    string word;
    int page, pageList[102][102], index = 1;
    rep(i,102) rep(j,102) pageList[i][j] = 5000;
    map<string,int> info;
    while(cin >> word >> page){
        if(info[word] > 0 && info[word] <= 102){
        }else{
            info[word] = index;
            index++;
        }
        int i = 0;
        while(true){
            if(pageList[ info[word] ][i] == 5000){
                pageList[info[word]][i] = page;
                break;
            }
            i++;
        }
    }
    rep(i,102){
        sort(pageList[i]);
    }
    map<string, int>::iterator it;
    for(it = info.begin(); it != info.end(); it++){
        cout << it->first << endl;
        rep(i,102){
            if(pageList[ it->second ][i] < 5000){
                if(i) cout << ' ';
                cout << pageList[ it->second ][i];
            }else break;
        }
        cout << endl;
    }
}