/*
	0105:book Index
*/
#include	<iostream>
#include	<vector>
#include	<utility>
#include	<string>
#include	<algorithm>

using namespace std;

typedef pair<string, int> P_SI;

int main(void) {
	string memstr = " ";
	vector<P_SI> words;
	
	while(1) {
		string buf_s;
		int buf_i;
		
		cin >> buf_s >> buf_i;
		if(cin.eof()) { break; }
		words.push_back( P_SI(buf_s, buf_i) );
	}
	sort( words.begin(), words.end() );
	
	vector<P_SI>::iterator it = words.begin();
	bool isFirst = true;
	while( it != words.end() ) {
		string buf_s = (*it).first;
		int buf_i = (*it).second;
		
		if(buf_s != memstr) {
			if(it != words.begin()) {
				cout << endl;
			}
			cout << buf_s << endl;
			memstr = buf_s;
			isFirst = true;
		}
		if(isFirst) {
			cout << buf_i;
			isFirst = false;
		} else {
			cout << ' ' << buf_i;
		}
		it++;
	}
	cout << endl;
	return 0;
}