#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;

int main(void){
	map<string,vector<int>> index;
	string s;
	int n;
	while(cin >>s >> n){
		index[s].push_back(n);
	}
	map<string,vector<int>>::iterator it;
	for( it = index.begin() ; it != index.end() ; ++it ){
        sort( it->second.begin() , it->second.end() );
         
        cout << it->first << endl;
        for(int i=0 ; i < it->second.size() ;i++){
            cout << it->second[i];
            ( i == it->second.size()-1 )? cout << endl : cout << " " ;
        }
    }
	return 0;
}