#include <bits/stdc++.h>
typedef struct {
  char name[20];
  char phone[200][20];
  int len[200];
  int avai[200];
  int cnt, now;
} friends;
friends frd[20];
int total;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char tmp[20];
    scanf("%s", tmp);
    int pos = -1;
    for (int j = 0; j < total; j++) {
      if (!strcmp(frd[j].name, tmp)) {
        pos = j;
        break;
      }
    }
    if (pos == -1) pos = total++;
    int num;
    scanf("%d", &num);
    for (int j = 0; j < num; j++) {
      char ph_num[20];
      scanf("%s", ph_num);
      int l = strlen(ph_num), flag = 0;
      for (int k = 0; k < frd[pos].now; k++) {
        if (frd[pos].avai[k]) {
          if (frd[pos].len[k] >= l) {
            if (!strcmp(frd[pos].phone[k] + frd[pos].len[k] - l, ph_num)) {
              flag = 1;
              break;
            }
          } else {
            if (!strcmp(ph_num + l - frd[pos].len[k], frd[pos].phone[k])) {
              frd[pos].avai[k] = 0;
              frd[pos].cnt--;
              break;
            }
          }
        }
      }
      if (!flag) {
        strcpy(frd[pos].name, tmp);
        strcpy(frd[pos].phone[frd[pos].now], ph_num);
        frd[pos].len[frd[pos].now] = l;
        frd[pos].avai[frd[pos].now] = 1;
        frd[pos].cnt++;
        frd[pos].now++;
      }
    }
  }
  printf("%d\n", total);
  for (int i = 0; i < total; i++) {
    printf("%s %d", frd[i].name, frd[i].cnt);
    for (int j = 0; j < frd[i].now; j++) {
      if (frd[i].avai[j]) printf(" %s", frd[i].phone[j]);
    }
    printf("\n");
  }
  return 0;
}
