#include <bits/stdc++.h>
using namespace std;
map<string, int> ma, id, tmp;
string st[100], ss;
vector<string> vc[100], ans[100];
int main() {
  int n;
  cin >> n;
  int c = 0;
  for (int i = 0; i < n; i++) {
    cin >> ss;
    ma[ss]++;
    if (ma[ss] == 1) {
      id[ss] = c;
      st[c] = ss;
      c++;
    }
    int m;
    string v;
    cin >> m;
    for (int j = 0; j < m; j++) {
      cin >> v;
      vc[id[ss]].push_back(v);
    }
  }
  int ck;
  for (int i = 0; i < c; i++) {
    for (int j = 0; j < vc[i].size(); j++) {
      ck = 1;
      for (int k = 0; k < vc[i].size(); k++) {
        ck = 0;
        if (vc[i][k].size() > vc[i][j].size()) {
          int m = vc[i][k].size();
          for (int l = vc[i][j].size() - 1; l >= 0; l--) {
            m--;
            if (vc[i][k][m] != vc[i][j][l]) ck = 1;
          }
        } else
          ck = 1;
        if (ck == 0) k = vc[i].size();
      }
      if (ck == 0) vc[i][j] = "a";
    }
  }
  for (int i = 0; i < c; i++) {
    tmp.clear();
    for (int j = 0; j < vc[i].size(); j++) {
      if (vc[i][j] != "a") {
        tmp[vc[i][j]]++;
        if (tmp[vc[i][j]] == 1) {
          ans[i].push_back(vc[i][j]);
        }
      }
    }
  }
  printf("%d\n", c);
  for (int i = 0; i < c; i++) {
    cout << st[i] << " ";
    cout << ans[i].size();
    for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j];
    cout << endl;
  }
}
