#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;

int main(){
  pair< string ,int > book[1001];
  string name;
  int n=0 ,num;
  bool flag=true;
  while( cin >> name >> num ){
    book[n].first  = name;
    book[n].second = num;
    n++;
  }

  sort( book ,book+n );
  for( int i=0 ; i<n ; i++ ){
    for( int j=0 ; j<n ; j++ ){
      if( i != j && book[i].first.find(book[j].first) != string::npos ){
	book[j].first = ' ';
      }
    }
  }
  for( int i=0 ; i<n ; i++ ){
    if( book[i].first.compare( " " ) == 0 )
      cout << ' ' << book[i].second;
    else{
      if( !i ){
	cout << book[i].first << endl << book[i].second;
	flag = true;
      }
      else{
	cout << endl << book[i].first << endl << book[i].second;
	flag = false;
      }
    }
  }
  if( !flag ) cout << endl;
}