/* -- 0105:Book Index -- */

#include	<iostream>
#include	<string>
#include	<vector>
#include	<utility>
#include	<algorithm>

using namespace std;

typedef pair< string, int > P;
typedef vector< P > Vec_S_I;

int main(void) {
	Vec_S_I Indexes;
	int buf_i, c;
	string buf_s;
	bool mstFirst = true, i_First = true;
	
	while(1) {
		cin >> buf_s >> buf_i;
		
		if( cin.eof() ) { break; }
		Indexes.push_back(P(buf_s, buf_i));
	}
	sort(Indexes.begin(), Indexes.end());
	Vec_S_I::iterator it = Indexes.begin();
	buf_s.erase();
	while(it != Indexes.end()) {
		if(buf_s != it->first) {
			if(!mstFirst) { cout << endl; }
			cout << it->first << endl;
			buf_s = it->first;
			i_First = true;
		}
		if(!i_First) { cout << ' '; }
		cout << it->second;
		i_First = false;
		mstFirst = false;
		it++;
	}
	return 0;
}