
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()
#define ITE(c) typeof((c).begin())

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

using namespace std;

int main(){
	bool flag=true;
	multimap<string,int> dat;
	pair<string,int>  temp;
	vector<string>    memo;
	vector<int>       page;
	
	while(cin>>temp.first>>temp.second){
		dat.insert(temp);
	}
	EACH(i,dat){
		if(!(*i).first.empty()){
			pair<typeof((dat).begin()),typeof((dat).begin())> tdat=dat.equal_range((*i).first);
			ITE(memo) find_it =find(memo.begin(),memo.end(),(*i).first);
			if( find_it == memo.end()){
				if(flag){
					cout<<(*i).first<<endl;
					flag=false;
				}else{
					cout<<"\n"<<(*i).first<<endl;
				}
				memo.push_back((*i).first);
				page.clear();
			    for (typeof((dat).begin()) it = tdat.first; it != tdat.second; ++it){
		        	page.push_back((*it).second);
		        }
		        sort(ALL(page));
		        int j=0;
		        EACH(i,page){
		        	j++;
		        	if(j<page.size()){
						cout<<(*i)<<" ";
					}else{
						cout<<(*i);
					}
		        }
		    }
		}
	}
	
	
	cout<<endl;
	
	return 0;
}