#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;

int main(){
	map< string, map<int,int> > table;
	string word;
	int n;
	while(cin>>word>>n){
		table[word][n]++;
	}
	for(map<string, map<int,int> >::iterator it = table.begin();it!=table.end();++it){
		cout<<it->first<<endl;
		map<int,int> w = it->second;
		for(map<int,int>::iterator it2 = w.begin();it2!=w.end();++it2){
			cout<<it2->first<<" ";
		}
		cout<<endl;
	
	}
	return 0;		
}