#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string names[n];
  vector<vector<string>> g(21);
  set<string> un;
  vector<vector<string>> ans(210);
  string unnames[n];
  int sz = 0;
  for (int i = 0; i < n; i++) {
    cin >> names[i];
    un.insert(names[i]);
    int tmp;
    cin >> tmp;
    for (int j = 0; j < tmp; j++) {
      string tmp2;
      cin >> tmp2;
      g[i].push_back(tmp2);
    }
  }
  for (auto i : un) {
    bool zhrv = true;
    for (int j = 0; j < sz; j++) {
      if (i == unnames[j]) {
        zhrv = false;
      }
    }
    if (zhrv) {
      unnames[sz] = i;
      sz++;
    }
  }
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j < n; j++) {
      if (unnames[i] == names[j]) {
        for (auto k : g[j]) {
          ans[i].push_back(k);
        }
      }
    }
  }
  vector<vector<string>> finally(210);
  for (int i = 0; i < sz; i++) {
    for (int j = 0; j < ans[i].size(); j++) {
      bool zhrv = true;
      if (ans[i][j].length() > 11) {
        zhrv = false;
      }
      for (int k = j + 1; k < ans[i].size(); k++) {
        if (ans[i][j].size() <= ans[i][k].size()) {
          bool a24 = true;
          string s1 = ans[i][j];
          string s2 = ans[i][k];
          int q = 0;
          for (int z = ans[i][k].size() - ans[i][j].size();
               z < ans[i][k].size(); z++) {
            if (s1[q] != s2[z]) {
              a24 = false;
            }
            q++;
          }
          if (a24) {
            zhrv = false;
          }
        } else {
          bool a24 = true;
          string s1 = ans[i][j];
          string s2 = ans[i][k];
          int q = 0;
          for (int z = ans[i][j].size() - ans[i][k].size();
               z < ans[i][j].size(); z++) {
            if (s1[z] != s2[q]) {
              a24 = false;
            }
            q++;
          }
          if (a24) {
            ans[i][k] = "HelloChernyshovnn";
          }
        }
      }
      if (zhrv) {
        finally[i].push_back(ans[i][j]);
      }
    }
  }
  cout << sz << endl;
  for (int i = 0; i < sz; i++) {
    cout << unnames[i] << " " << finally[i].size() << " ";
    for (auto j : finally[i]) {
      cout << j << " ";
    }
    cout << endl;
  }
  return 0;
}
