#include<iostream>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<string>
#include<utility>
using namespace std;
int main() {
	vector<pair<string, int>> p;
	string str;
	vector<int>num(10000);
	int n,pos=0;
	while (cin >> str) {
		cin >> n;
		p.push_back(pair<string, int>(str, n));
	}
	sort(p.begin(),p.end());
	auto itr = p.begin();
	cout << itr->first << endl << itr->second;
	itr++;
	while (itr!=p.end()) {
		if ( (itr - 1)->first == itr->first) {
			cout << " " << itr->second ;
		}
		else {
			cout <<endl<< itr->first << endl<<itr->second;
		}
		itr++;
	}cout << endl;
	return 0;
}
