#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main() {
	map<string, vector<int>>l;
	vector<string>str;
	while (!cin.eof()){
		string s;
		int n;
		cin >> s >> n;
		l[s].push_back(n);
		sort(l[s].begin(), l[s].end());
		if (find(str.begin(), str.end(), s) == str.end()) {
			str.push_back(s);
		}
	}
	sort(str.begin(), str.end());
	for (string i : str){
		cout << i << endl;
		for (int j = 0; j < l[i].size(); j++){
			cout << l[i][j];
			if (j != l[i].size() - 1)cout << ' ';
		}
		cout << endl;
	}
	return 0;
}