#include<iostream>
#include<functional>
#include<string>
#include<map>
#include<queue>
#include<vector>
#include<set>
using namespace std;
typedef pair<string,int> P;
int main(){
	string s,temp;
	int x;
	set<int> que;
	multimap<string,int> box;
	while(cin>>s>>x)
		box.insert(P(s,x));
	box.insert(P("zzzzzzz",0));
	multimap<string,int>::iterator ite;
	for(ite=box.begin();ite->second!=0;){
		temp=ite->first;
		que.insert(ite->second);
		ite++;
		while(ite->first==temp){
			que.insert(ite->second);
			ite++;
		}
		cout<<temp<<endl;
		set<int>::iterator se=que.begin();
		cout<<*se;
		se++;
		while(se!=que.end()){
			cout<<' '<<*se;
			se++;
		}
		cout<<endl;
		que.clear();
	}
	return 0;
}