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

struct Data{
  string name;
  int page;

  bool operator < (const Data &data)const{
    if(name==data.name){
      if(page<data.page) return true;
      else return false;
    }else{
      if(name<data.name) return true;
      else return false;
    }
  }
};

int main(){

  Data a[110];
  string s;
  int n, i=0;

  while(cin>>s>>n){
    a[i]=(Data){s, n};
    i++;
  }

  sort(a, a+i);

  string key="";

  n=i;
  for(i=0;i<n;i++){
    if(key!=a[i].name){
      key=a[i].name;
      if(i>0){
	cout<<endl;
      }
      cout<<key<<endl;
      cout<<a[i].page;
    }else{
      cout<<" "<<a[i].page;
    }
  }

  cout<<endl;
  
  
  return 0;
}