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

int main() {
	map<string, vector<int> > book;
	string title;
	int page;
	while(cin >> title >> page) {
		book[title].push_back(page);
	}
	for(map<string, vector<int> >::iterator itr = book.begin(); itr != book.end(); itr++) {
		printf("%s\n", (*itr).first.c_str());
		for(vector<int>::iterator sc = (*itr).second.begin(); sc != (*itr).second.end(); sc++) {
			printf("%d ", *sc);
		}
		printf("\n");
	}
	return 0;
}