#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	vector<pair<string, int>> data;

	string str;
	int a;
	while (cin >> str >> a) {
		data.push_back(pair<string, int>(str, a));
    }
	sort(data.begin(), data.end());
	
	pair<string, int> preData;
	for (pair<string, int> e: data) {
		if (preData.first == e.first) {
			cout << " " << e.second;
		} else {
			cout << endl << e.first << endl << e.second;
		}
		preData = e;
	}

    return 0;
}