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

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