#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
using namespace std;

int main(){
	string s;
	int n;
	map<string, vector<int> > m;
	while (1){
		if (cin.eof()) break;
		cin >> s >> n;
		m[s].push_back(n);
	}
	map<string, vector<int> >::iterator it = m.begin();
	while (it != m.end()){
		int flag = 0;
		cout << (*it).first << endl;
		sort((*it).second.begin(), (*it).second.end());
		for (int i = 0; i < (*it).second.size(); i++){
			if (!flag){
				cout << (*it).second[i];
				flag = 1;
			}
			else cout << " " << (*it).second[i];
		}
		cout << endl;
		++it;
	}
	return 0;
}