#include <bits/stdc++.h>
using namespace std;
int n, id;
class people {
 public:
  int cnt, real;
  string name, str[210];
  bool bad[210];
  people() {
    cnt = real = 0;
    memset(bad, 0, sizeof bad);
  }
} p[25];
map<string, int> f;
bool pro(string a, string b) {
  if (a.length() > b.length()) return false;
  int lenA = a.length();
  int lenB = b.length();
  for (int i = 0; i < lenA; i++) {
    if (b[lenB - 1 - i] == a[lenA - 1 - i])
      continue;
    else
      return false;
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int tmp, i = 1; i <= n; i++) {
    string name;
    cin >> name;
    int x = f[name];
    if (x) {
      scanf("%d", &tmp);
      for (int j = 1; j <= tmp; j++) {
        cin >> p[x].str[++p[x].cnt];
      }
    } else {
      f[name] = ++id;
      p[id].name = name;
      scanf("%d", &tmp);
      for (int j = 1; j <= tmp; j++) {
        string s;
        cin >> s;
        p[id].str[++p[id].cnt] = s;
      }
    }
  }
  cout << id << endl;
  for (int i = 1; i <= id; i++) {
    people &a = p[i];
    for (int j = 1; j <= a.cnt; j++) {
      if (a.bad[j]) continue;
      for (int k = j + 1; k <= a.cnt; k++) {
        if (a.bad[k]) continue;
        if (pro(a.str[j], a.str[k])) a.bad[j] = true;
        if (a.bad[k] || a.bad[j]) continue;
        if (pro(a.str[k], a.str[j])) a.bad[k] = true;
      }
    }
    a.real = 0;
    for (int j = 1; j <= a.cnt; j++)
      if (a.bad[j] == false) a.real++;
    cout << a.name << " " << a.real << " ";
    for (int j = 1; j <= a.cnt; j++)
      if (a.bad[j] == false) cout << a.str[j] << " ";
    cout << endl;
  }
  return 0;
}
