#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define VS vector<string>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back

using namespace std;

int main(){
    map<string, vector<int> > m;
    string s; int p;
    while(cin >> s >> p){
        m[s].push_back(p);
    }
    map<string, vector<int> >::iterator it = m.begin();
    while( it != m.end() ){
        cout << (*it).first << endl;
        sort(all((*it).second));
        for(int i=0; i < (*it).second.size(); i++){
            if(i != 0) cout << " " << (*it).second[i];
            else cout << (*it).second[i];
        }
        cout << endl;
        ++it;
    }
}