#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(itr,c) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

int main(){
  int page;
  string doc;
  map< string, vector<int> > mp;

  while(cin >> doc >> page) mp[doc].push_back(page);

  int i;
  foreach(itr,mp){
    cout << itr->first << endl;
    sort(itr->second.begin(),itr->second.end());
    rep(i,itr->second.size()){
      cout << itr->second[i];
      if(itr->second.size()-1 == i) cout << endl; else cout << ' ';
    }
  }

  return 0;
}