#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  map<string,set<int> > m;
  string str;
  int n;
  while(cin>>str>>n) m[str].insert(n);
  FOR(mit,m){
    bool f = false;
    cout << mit->first << endl;
    FOR(sit,mit->second){
      if(!f){
        f = true;
      }else{
        cout << " ";
      }
      cout << *sit;
    }
    cout << endl;
  }
  return 0;
}