#include <stdio.h>
#include <string.h>

int main(void)
{
	char w[1024];
	char p[1024];
	char word[128][1024];
	char page[128][1024];
	char tmp[1024];
	int i;
	int j;
	int n;
	
	i = 0;
	while (scanf("%s %s", w, p ) != EOF){
		word[i][0] = '\0';
		i++;
		for (j = 0; j <= i; j++){
			if (strcmp(word[j], w) == 0){
				strcat(page[j], " ");
				strcat(page[j], p);
				i--;
			}
			if (word[j][0] == '\0'){
				strcpy(word[j], w);
				strcpy(page[j], p);
			}
		}
	}
	n = i;
	for (i = 0; i < n; i++){
		for (j = n; j > i; j--){
			if (strcmp(word[j], word[j - 1]) < 0){
				strcpy(tmp, word[j]);
				strcpy(word[j], word[j - 1]);
				strcpy(word[j - 1], tmp);
				strcpy(tmp, page[j]);
				strcpy(page[j], page[j - 1]);
				strcpy(page[j - 1], tmp);
			}
		}
	}
	
	for (i = 0; i <= n; i++){
		printf("%s\n%s\n", word[i], page[i]);
	}
	
	return (0);
}