#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int temp;
	int k,page;
	int i,flag=0;
	int j,count=0;
	string word;
	string index[1000];
	int num[1000][100];
	int appe[1000][2];
	memset(num,0,sizeof(num));
	memset(appe,0,sizeof(appe));
	for(i=0;i<1000;i++)
	{
		index[i]="";
	}
	while(cin>>word>>page)
	{
		for(j=0;j<flag;j++)
		{
			if(word.compare(index[j])!=0)
			{
				count++;
			}
			else
			{
				for(k=0;k<100;k++)
				{
					if(num[j][k]==0)
					{
						num[j][k]=page;
						break;
					}
				}
			}
		}

		if(count==flag)
		{
			index[flag]=word;
			num[flag][0]=page;
			appe[flag][0]=flag;
			appe[flag][1]=word.at(0)-'a';
		}
		count=0;
		flag++;
	}

	for(i=0;i<flag;i++)
	{
		for(j=0;j<flag-1-i;j++)
		{
			if(appe[j][1]>appe[j+1][1])
			{
				temp=appe[j][1];
				appe[j][1]=appe[j+1][1];
				appe[j+1][1]=temp;

				temp=appe[j][0];
				appe[j][0]=appe[j+1][0];
				appe[j+1][0]=temp;
			}
		}
	}

	for(i=0;i<flag;i++)
	{
		j=0;
		cout<<index[appe[i][0]]<<endl;		

		while(num[appe[i][0]][j]!=0)
		{
			cout<<num[appe[i][0]][j]<<" ";
			j++;
		}
		cout<<endl;
	}
	return 0;
}