#include <bits/stdc++.h>
using namespace std;
class friends {
 public:
  string name;
  int n;
  vector<string> A;
};
bool compare_names(friends a, friends b) { return (a.name < b.name); }
int main() {
  ios::sync_with_stdio(0);
  int k;
  cin >> k;
  friends F[20];
  string st;
  for (int i = 0; i < k; i++) {
    cin >> F[i].name;
    cin >> F[i].n;
    for (int j = 0; j < F[i].n; j++) {
      cin >> st;
      F[i].A.push_back(st);
    }
  }
  sort(F, F + k, compare_names);
  int real_k = k;
  for (int i = 0; i < k - 1; i++) {
    if (F[i].name == F[i + 1].name) {
      real_k--;
      for (int j = 0; j < F[i].A.size(); j++) {
        F[i + 1].A.push_back(F[i].A[j]);
      }
      F[i].name = " ";
    }
  }
  for (int i = 0; i < k; i++) {
    if (F[i].name != " ") {
      for (int j = 0; j < F[i].A.size(); j++) {
        for (int q = j + 1; q < F[i].A.size(); q++) {
          if (F[i].A[j] == F[i].A[q])
            F[i].A[q] = " ";
          else if (F[i].A[j].size() > F[i].A[q].size()) {
            if (F[i].A[j].substr(F[i].A[j].size() - F[i].A[q].size(),
                                 F[i].A[j].size()) == F[i].A[q])
              F[i].A[q] = " ";
          } else if (F[i].A[j].size() < F[i].A[q].size()) {
            if (F[i].A[q].substr(F[i].A[q].size() - F[i].A[j].size(),
                                 F[i].A[q].size()) == F[i].A[j])
              F[i].A[j] = " ";
          }
        }
      }
    }
  }
  cout << real_k << endl;
  for (int i = 0; i < k; i++) {
    if (F[i].name != " ") {
      cout << F[i].name << " ";
      F[i].n = 0;
      for (int j = 0; j < F[i].A.size(); j++) {
        if (F[i].A[j] != " ") F[i].n++;
      }
      cout << F[i].n << " ";
      for (int j = 0; j < F[i].A.size(); j++) {
        if (F[i].A[j] != " ") cout << F[i].A[j] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
