#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

int main()
{
	int n = 0;
	vector<pair<string, int> > v = vector<pair<string, int> >(100);
	while (cin >> v[n].first >> v[n].second)
		n++;
	n++;
	for (int i = 0; i < n; i++)
	{
		for (int j = i; j < n; j++)
		{
			if (v[i].first > v[j].first || (v[i].first == v[j].first && v[i].second > v[j].second))
			{
				pair<string, int> r = v[i];
				v[i] = v[j];
				v[j] = r;
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		int fin = n;
		for (int j = i; j < n; j++)
		{
			if (v[i].first != v[j].first)
			{
				fin = j;
				break;
			}
		}
		cout << v[i].first << endl;
		for (int j = i; j < fin - 1; j++)
			cout << v[j].second << " ";
		cout << v[fin - 1].second << endl;
		i = fin;
	}

	return 0;
}