#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <map>
using namespace std;

#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()

int main() {
  string s;
  int p;
  multimap<string, int> mm;
  while(cin>>s>>p) {
    mm.insert(make_pair(s,p));
  }
  string mae;
  int f = 0;
  FOR(it, mm) {
    string ima = (*it).first;
    vector<int> v;
    REP(i,mm.count(ima)) {
      v.push_back((*(it++)).second);
    }
    it--;
    sort(ALL(v));
    cout << ima << endl;
    REP(i,v.size()) {
      if (i) cout << " ";
      cout << v[i];
    }
    cout << endl;
  }
}