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

int main(void)
{
	char words[100][30] = {"\0"};
	char temp1[30];
	int number[100] = {0};
	int temp2;
	int i, j, k, n, m, t;

	for(i = 0; scanf("%s %d*c", words[i], &number[i]) != EOF; i++)
		;

	for (k = 0; k < 99; k++)
		for (i = 0; i < 100; i++)
			if (words[i + 1][0] != 0)
				for (j = 0; j < 30; j++)
					if (words[i][j] > words[i+1][j])
					{
						strcpy(temp1, words[i]);
					    strcpy(words[i], words[i+1]);
					    strcpy(words[i+1], temp1);

					    temp2 = number[i];
						number[i] = number[i+1];
						number[i+1] = temp2;

					    break;
					}
					else if (words[i][j] == words[i+1][j])
						continue;
					else
						break;
			else
				break;

	for (i = 0; i < 100; i++)
	{
		if (words[i][0] == NULL)
			break;
		if (strcmp(words[i], words[i+1]) != 0)
		{
			printf("%s\n", words[i]);
			printf("%d\n", number[i]);
		}
		else
		{
			for (n = 0; strcmp(words[i+n], words[i+n+1]) == 0; n++)
				;
			printf("%s\n", words[i]);

			for (t = 0; t < n; t++)
				for (m = 0; m < n; m++)
					if (number[i+m] > number[i+m+1])
					{
						temp2 = number[i+m];
						number[i+m] = number[i+m+1];
						number[i+m+1] = temp2;
					}

			for (m = 0; m <= n; m++)
			{
				printf("%d", number[i+m]);
				if (m == n)
					printf("\n");
				else
					printf(" ");
			}

			i += n;
		}
	}

	return 0;
}