//============================================================================
// Name        : aoj0105.cpp
// Author      : afterCmidday
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

typedef struct{
	char word[31];
	int page;
}Quate;

int compare(const void *a,const void *b){
	Quate qa, qb;
	qa = *(Quate *)a;
	qb = *(Quate *)b;
	if(strcmp(qa.word,qb.word) != 0){
		return strcmp(qa.word,qb.word);
	}else{
		return qa.page - qb.page;
	}
}


int main() {
	char tmp[31] = "";
	Quate q[1000];
	int n = 0, i;
	while(scanf("%s%d%*c",q[n].word,&q[n].page) != EOF){
		n++;
	}
	qsort(q,n,sizeof(q[0]),compare);
	for(i = 0;i < n;i++){
		if(strcmp(tmp,q[i].word) == 0){
			printf(" %d",q[i].page);
		}else{
			if(strcmp(tmp,"") != 0){
				printf("\n");
			}
			printf("%s\n%d",q[i].word,q[i].page);
		}
		strcpy(tmp,q[i].word);
	}
	printf("\n");

	return 0;
}