#include <bits/stdc++.h>
using namespace std;
bool cmp(string a, string b) { return a.size() > b.size(); }
int main() {
  int n, m, ncnt = 0, b[25];
  string name, nu;
  cin >> n;
  map<string, int> nmp;
  set<string> se;
  vector<string> v[25];
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; i++) {
    cin >> name;
    se.insert(name);
    if (nmp[name] == 0) {
      ncnt++;
      nmp[name] = ncnt;
    }
    cin >> m;
    for (int i = 1; i <= m; i++) {
      cin >> nu;
      v[nmp[name]].push_back(nu);
    }
    sort(v[nmp[name]].begin(), v[nmp[name]].end(), cmp);
  }
  map<string, int> nump[25];
  for (int i = 1; i <= ncnt; i++) {
    int cnt = 0;
    map<string, int> check;
    for (int j = 0; j < v[i].size(); j++) {
      if (nump[i][v[i][j]] == 0 && check[v[i][j]] == 0) {
        cnt++;
        check[v[i][j]] = 1;
        for (int l = 1; l < v[i][j].size(); l++) {
          string ss = v[i][j].substr(l, v[i][j].size() - l);
          nump[i][ss] = 1;
        }
      }
    }
    b[i] = cnt;
  }
  cout << se.size() << endl;
  for (set<string>::iterator it = se.begin(); it != se.end(); it++) {
    string ss = *it;
    cout << ss << " ";
    cout << b[nmp[ss]] << " ";
    map<string, int> check;
    for (int i = 0; i < v[nmp[ss]].size(); i++) {
      if (nump[nmp[ss]][v[nmp[ss]][i]] == 0 && check[v[nmp[ss]][i]] == 0) {
        check[v[nmp[ss]][i]] = 1;
        cout << v[nmp[ss]][i] << " ";
      }
    }
    cout << endl;
  }
}
