#include<iostream>
#include<string.h>
using namespace std;

void Swap(int& x,int& y);
void SWAP(char *x,char *y);



class Book{
	int count;
	char name[1000][30];
	int page[100][100] = {{0}};
	int stock[100] = { 0 };
public:
	void Set(int x);
	void IN(char *str,int pa);
	void OUT();
	void SORT();
};

void Book::Set(int x){
	int i,j,k,tmp;
	if(x == 0)
		count = 0;
	else{
		for(i = 0; i < count; i++){
			for(j = 0; j < stock[i]; j++){
				for( k = stock[i] - 1; j < k ; k--){
					if(page[i][j] > page[i][k]){
						tmp = page[i][j];
						page[i][j] = page[i][k];
						page[i][k] = tmp;
					}
				}
			}
		}
	}
}

void Book::OUT(){
	int i,j;

	for(i = 0; i < count; i++){
		cout << name [i] << endl;
		for(j = 0; j < stock[i]; j++){
			if(j > 0)
				cout << ' ';
			cout << page[i][j];
		}
		cout << endl;
	}
}

void Book::IN(char *str,int pa){
	int i,j,k,f=0,tmp;

	for(i = 0; i < count; i++){
		if((strcmp(name[i],str)) == 0){
			f++;
			page[i][stock[i]] = pa;
			stock[i]++;
			break;
		}
	}
	if(f == 0){
		count++;
		strcpy(name[count-1],str);
		page[count-1][ 0 ] = pa; 
		stock[i]++;
	}
}

void Book::SORT(){
	int i,j,k,tmp2,max;
	char tmp1[100];

	i = 0;
	j = count;

	for(i = 0; i < j ; i++){
		for(j = count - 1; j > i ; j--){
			if((strcmp(name[i],name[j]))){
				strcpy(tmp1,name[i]);
				strcpy(name[i],name[j]);
				strcpy(name[j],tmp1);

				if(stock[i] < stock[j]){
					for(k = stock[i]; k < stock[j]; k++)
						page[i][k] = page[j][k];
					max = stock[i];
				}
				else{
					for(k = stock[j]; k < stock[i]; k++)
						page[j][k] = page[i][k];
					max = stock[j];
				}

				for(k = 0; k < max ; k++){
					tmp2 = page[j][k];
					page[j][k] = page[i][k];
					page[i][k] = tmp2;
				}

				tmp2 = stock[i];
				stock[i] = stock[j];
				stock[j] = tmp2;
			}
		}
	}
}
 

int main(){
	int i,j,num;
	char str[30];
	Book index;


	index.Set(0);
	while(1){
		cin >> str;
		if( cin.eof() )break;
		cin >> num;

		index.IN(str,num);
	}
	index.Set(1);
	index.SORT();
	
	index.OUT();

	return 0;
}