#include<bits/stdc++.h>
using namespace std;
map<string,priority_queue<int,vector<int>,greater<int> > > Map;
signed main(void){
	ios::sync_with_stdio(false);
	string s;
	int page;
	while(cin>>s>>page)
		Map[s].push(page);
	for(map<string,priority_queue<int,vector<int>,greater<int> > >::iterator it=Map.begin();it!=Map.end();++it){
		cout<<it->first<<endl;
		while(!it->second.empty()){
			cout<<it->second.top()<<" ";
			it->second.pop();
		}
		cout<<endl;
	}
}