#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  string str;
  map<string,vector<int> > dic;
  while((cin >> str)){
    int p;cin >> p;
    dic[str].push_back(p);
  }
  map<string,vector<int> >::iterator it = dic.begin();
  while( it != dic.end() ){
    cout << (*it).first << endl;
    sort((*it).second.begin(),(*it).second.end());
    cout << (*it).second[0];
    for(int i = 1;i < (*it).second.size();i++){
      cout << " " <<(*it).second[i];
    }
    cout << endl;
    ++it;
  }
  return 0;
}