#include<iostream>
#include<algorithm>

using namespace std;

struct Data{
  string name;
  int num;
  bool operator < ( const Data &data) const {
    return (name < data.name);
  }
};

int main(){
  
  Data a[100000];
  int n=0;
  string str;
  int id;
  while( cin>>str>>id ){
    a[n]= (Data){ str, id };
    n++;
  }
  sort(a,a+n);

  string key="";
  
  for(int 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].num;
    }else{
      cout<<' '<<a[i].num;
    }
  }

  cout<<endl;
  
  return 0;
}