#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

typedef pair<string,int> P;
typedef pair<int,string> P2;

int main() {
  string s;
  P2 a[101];
  int cnt=0;
  while(cin >> s) {
    int n;
    cin >> n;
    a[cnt]=P2(n,s);
    cnt++;
  }
  sort(a,a+cnt);
  P b[cnt];
  for(int i=0; i<cnt; i++) b[i]=P(a[i].second,a[i].first);
  sort(b,b+cnt);
  
  string name="";
  bool ck=false;
  for(int i=0; i<cnt; i++) {
    if(b[i].first!=name) {
      if(ck) cout << endl;
      cout << b[i].first << endl;
      name=b[i].first;
      ck=false;
    }
    if(ck) cout << " ";
    cout << b[i].second;
    ck=true;
  }
  cout << endl;
  return 0;
}
	
