#include<cstdio>
#include<map>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(void)
{
	map < string, vector<int> > index;

	char cbuf[31];
	int ibuf;

	while (scanf("%s %d", cbuf, 31, &ibuf) != EOF)
	{
		index[cbuf].push_back(ibuf);
	}

	for (auto &elem : index)
	{
		sort(elem.second.begin(), elem.second.end());
		printf("%s\n", elem.first.c_str());
		for (auto &vecElem : elem.second)
		{
			printf("%d ", vecElem);
		}
		printf("\n");
	}

	return 0;
}