#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  int n;
  map<string, vector<int>> mp;
  while (cin >> s >> n) {
    mp[s].emplace_back(n);
  }
  for (auto i : mp) {
    cout << i.first << endl;
    auto v = i.second;
    int vz = v.size();
    sort(v.begin(), v.end());
    for (int j = 0; j < vz; j++) {
      cout << v[j] << " \n"[j + 1 == vz];
    }
  }

  return 0;
}
