#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>

using namespace std;


string w,p;


int main(){
    map<string, string> book;
    
    while(cin>>w>>p){
        if(book.find(w)==book.end()){
            book[w]=p;
        }else{
            book[w]=book[w]+" "+p;
        }
    }
    
    for (map<string, string>::iterator itr = book.begin(); itr != book.end(); itr++)
	{
		// キーを出力
		cout << itr->first << endl;
		// 値を出力
		cout << itr->second << endl;
	}
    
}