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

int main()
{
	vector<pair<string, vector<int> > > v = vector<pair<string, vector<int> > >();
	string s;
	int n;
	while (cin >> s >> n)
	{
		int ok = true;
		for (int i = 0; i < v.size(); i++)
		{
			if (v[i].first == s)
			{
				ok = false;
				v[i].second.push_back(n);
			}
		}
		if (ok)
			v.push_back({ s,{n} });
	}
	for (int i = 0; i < v.size(); i++)
		sort(v[i].second.begin(), v[i].second.end());
	for(int i = 0; i < v.size(); i++)
		for (int j = i + 1; j < v.size(); j++)
		{
			if (v[i].first > v[j].first)
			{
				pair<string, vector<int> > r = v[i];
				v[i] = v[j];
				v[j] = r;

			}
		}
	for (int i = 0; i < v.size(); i++)
	{
		cout << v[i].first << endl;
		for (int j = 0; j < v[i].second.size() - 1; j++)
		{
			cout << v[i].second[j] << " ";
		}
		cout << *(v[i].second.end()) << endl;
	}

	return 0;
}