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

class cob{
public:
	string str;
	vector<int> num;
	cob(string str):str(str){}

	bool operator < (const cob &ano){
		if(str != ano.str)
			return str < ano.str;
		else
			return false;
	}

	void S()
	{
		sort(num.begin(), num.end());
	}
};



int main(void)
{
	string instr;
	int num;
	vector<cob> index;

	bool f = false;
	while(cin >> instr >> num, !cin.eof()){
		for(int i = 0; i < index.size(); i++){
			if(index[i].str == instr){			
				index[i].num.push_back(num);
				f = true;
				break;
			}
		}
		if(!f){
			index.push_back(cob(instr));
			index.back().num.push_back(num);
		}
	}

	sort(index.begin(), index.end() );
	for(int i = 0; i < index.size(); i++){
		index[i].S();

		cout << index[i].str << endl;
		cout << index[i].num[0];
		for(int j = 1; j < index[i].num.size(); j++)
			cout << ' ' << index[i].num[j];
		cout << endl;
	}

	return 0;
}