#include <stdio.h>
#include <string.h>

struct data {
  char id[30];
  int stk[100];
  int sp;
} d[1000];

int main() {
  char id[30];
  int val;
  int i, j, k, dp = 0, f, t;
  struct data tmp;
  while (scanf("%s %d", id, &val) != EOF) {
    f = 0;
    for (i = 0; i < dp; i++) {
      if (strcmp(id, d[i].id) == 0) {
        f = 1;
        break;
      }
    }
    if (f == 1) {
      d[i].stk[d[i].sp++] = val;
    } else {
      strcpy(d[dp].id, id);
      d[dp].stk[d[dp].sp++] = val;
      dp++;
    }
  }
  for (i = 0; i < dp; i++)
    for (j = dp - 1; j > 0; j--)
      if (strcmp(d[j - 1].id, d[j].id) > 0) {
        tmp = d[j - 1];
        d[j - 1] = d[j];
        d[j] = tmp;
      }
  for (i = 0; i < dp; i++) {
    printf("%s\n", d[i].id);
    for (j = 0; j < d[i].sp; j++)
      for (k = d[i].sp - 1; k > 0; k--)
        if (d[i].stk[k - 1] > d[i].stk[k]) {
          t = d[i].stk[k - 1];
          d[i].stk[k - 1] = d[i].stk[k];
          d[i].stk[k] = t;
        }
    for (j = 0; j < d[i].sp; j++)
      printf("%d ", d[i].stk[j]);
    printf("\n");
  }

  return 0;
}