#include <bits/stdc++.h>
using namespace std;
long long int MIN(long long int a, long long int b) { return (a < b) ? a : b; }
long long int MAX(long long int a, long long int b) { return (a > b) ? a : b; }
long long int ABS(long long int x) { return (x > 0) ? x : -x; }
int MIN(int a, int b) { return (a < b) ? a : b; }
int MAX(int a, int b) { return (a > b) ? a : b; }
int ABS(int x) { return (x > 0) ? x : -x; }
double MIN(double a, double b) { return (a < b) ? a : b; }
double MAX(double a, double b) { return (a > b) ? a : b; }
double ABS(double a, double b) { return (a > 0) ? a : b; }
long long int left(long long int x) { return (x << 1); }
long long int right(long long int x) { return (x << 1) + 1; }
long long int lsone(long long int x) { return (x & (-x)); }
int n, m, maxIdx = -1, siz[300];
char tmpName[300], tmpPhone[300];
char name[300][300], phone[300][300][300];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int idx = maxIdx + 1;
    scanf("%s", tmpName);
    for (int j = 0; j < i; j++) {
      if (strcmp(tmpName, name[j]) == 0) idx = j;
    }
    if (idx == maxIdx + 1) strcpy(name[idx], tmpName);
    maxIdx = MAX(maxIdx, idx);
    scanf("%d", &m);
    for (int j = 0; j < m; j++) {
      scanf("%s", tmpPhone);
      bool isSub = false;
      for (int k = 0; k < siz[idx]; k++) {
        int lSize = strlen(phone[idx][k]), rSize = strlen(tmpPhone);
        bool isSubHere = true;
        if (lSize < rSize) {
          for (int l = 0; l < lSize; l++) {
            if (phone[idx][k][l] != tmpPhone[l + rSize - lSize])
              isSubHere = false;
          }
          if (isSubHere) {
            isSub = true;
            strcpy(phone[idx][k], tmpPhone);
          }
        } else {
          for (int l = 0; l < rSize; l++) {
            if (phone[idx][k][l + lSize - rSize] != tmpPhone[l])
              isSubHere = false;
          }
          if (isSubHere) {
            isSub = true;
          }
        }
        if (isSub) break;
      }
      if (isSub)
        continue;
      else {
        strcpy(phone[idx][siz[idx]], tmpPhone);
        siz[idx]++;
      }
    }
  }
  printf("%d\n", maxIdx + 1);
  for (int i = 0; i <= maxIdx; i++) {
    printf("%s %d", name[i], siz[i]);
    for (int j = 0; j < siz[i]; j++) printf(" %s", phone[i][j]);
    printf("\n");
  }
}
