#include<iostream>
#include<map>
#include<algorithm>

using namespace std;

int main(){

  /* map<string, int(doubleÅà½Åà¢¢)> M;
           1      2
          Y    l

1©çQðQÆÅ«éæ¤É·éB
string s;
s = "abcd";

M[s] = 3;
cout << M[s] < endl;
oÍ
R
  */

  string s[1000];
  int n;
  int i =0;
    
  map<string, int> M;
  
  while(cin >> s[i] >> n){

    M[s[i]] = n;
    // cout << "M[s[i]] =="<< M[s[i]] << endl;
    i++;
  }

  sort(s,s+i);

    for(int j = 0; j < i; j++){
      if(j != 0 && s[j] == s[j-1]){
	cout << " "<< M[s[j]];
      }else if(j != 0){
	cout << endl << s[j] << endl <<M[s[j]];
      }else{
	cout <<s[j]<< endl << M[s[j]];
      }
    }

    cout << endl;


    return 0;

}