#include <bits/stdc++.h>
char ch;
bool fs;
void re(int& x) {
  while (ch = getchar(), ch < 33)
    ;
  if (ch == '-')
    fs = 1, x = 0;
  else
    fs = 0, x = ch - 48;
  while (ch = getchar(), ch > 33) x = x * 10 + ch - 48;
  if (fs) x = -x;
}
using namespace std;
int n, cnt;
string name[50];
map<string, int> s;
vector<string> p[50], q[50];
int main() {
  re(n);
  for (int i = 1; i <= n; ++i) {
    string a;
    cin >> a;
    if (!s[a]) s[a] = ++cnt, name[cnt] = a;
    int t = s[a];
    int w;
    cin >> w;
    while (w--) {
      cin >> a;
      p[t].push_back(a);
    }
  }
  for (int i = 1; i <= cnt; ++i)
    for (int j = 0; j < p[i].size(); ++j) {
      bool find = 0;
      for (int k = 0; k < p[i].size(); ++k) {
        bool ok = 1;
        if (p[i][k].size() < p[i][j].size()) continue;
        for (int l = 0; l < p[i][j].size(); ++l)
          if (p[i][j][l] != p[i][k][p[i][k].size() - p[i][j].size() + l])
            ok = 0;
        if (ok && (p[i][j] != p[i][k] || j < k)) find = 1;
      }
      if (!find) q[i].push_back(p[i][j]);
    }
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; ++i) {
    cout << name[i] << " " << q[i].size() << " ";
    for (int j = 0; j < q[i].size(); ++j) cout << q[i][j] << " ";
    puts("");
  }
}
