#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string str;
  int page;
  vector<pair<string, int>> vec;

  while (cin >> str >> page)
    vec.push_back(make_pair(str, page));

  sort(vec.begin(), vec.end(), [](auto &a, auto &b) {
    return (a.first != b.first) ? a.first < b.first : a.second < b.second;
  });

  string last = "";
  for (auto &v : vec) {
    if (last == v.first) {
      cout << " " << v.second;
   } else {
      if (last != "")
        cout << endl;
      cout << v.first << endl << v.second;
    }
    last = v.first;
  }
  cout << endl;
}
