#include<iostream>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

int main(void){

	string index;
	int page;
	map<string,set<int> >dic;
	
	while(cin >> index >> page)
		dic[index].insert(page);
	
	 map<string,set<int> >::iterator it = dic.begin();
    for(;it != dic.end();it++){
        cout << it->first << endl;
    	
        set<int>::iterator its = (it->second).begin();
    	
        while(its != (it->second).end()){
            cout << *its;
            cout << (++its != (it->second).end() ? " " : endl);
        }
    }
	
return 0;
}