#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string buf;
	int p;
	std::map<std::string, std::vector<int> > map;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	std::cin.rdbuf(ifs.rdbuf());
#endif

	while(std::cin >> buf >> p){
		map[buf].push_back(p);
	}

	for(std::map<std::string, std::vector<int> >::const_iterator it = map.begin(); it != map.end(); it++){
		std::vector<int> pages = it->second;
		std::sort(pages.begin(), pages.end());

		std::cout << it->first << std::endl;
		std::cout << pages[0];
		for(int i = 1; i < pages.size(); i++){
			std::cout << " " << pages[i];
		}
		std::cout << std::endl;
	}


#if INPUT_FROM_FILE
		//fclose(fp);
#endif
	return 0;
}

