#include <bits/stdc++.h>
using namespace std;
vector<string> v[101];
vector<string> v2[101];
bool issuffix(string a, string b) {
  int n = a.length(), m = b.length(), i, j;
  j = m - 1 - (n - 1);
  for (i = 0; i < n; ++i)
    if (a[i] != b[j + i]) return false;
  return true;
}
bool comp(string a, string b) { return a.length() < b.length(); }
int main() {
  std::ios::sync_with_stdio(false);
  int T;
  T = 1;
  while (T--) {
    string str[101], second;
    int n, i, j, k, pos, x, z, y, flag;
    cin >> n;
    j = 0;
    for (i = 0; i < n; ++i) {
      cin >> second;
      pos = j;
      for (k = 0; k < j; ++k)
        if (str[k] == second) {
          pos = k;
          break;
        }
      if (pos == j) str[j] = second;
      cin >> x;
      while (x > 0) {
        cin >> second;
        v[pos].push_back(second);
        --x;
      }
      if (pos == j) ++j;
    }
    for (i = 0; i < j; ++i) {
      sort(v[i].begin(), v[i].end(), comp);
      for (k = 0; k < v[i].size(); ++k) {
        flag = 0;
        for (x = k + 1; x < v[i].size(); ++x)
          if (issuffix(v[i][k], v[i][x])) {
            flag = 1;
            break;
          }
        if (flag == 0) v2[i].push_back(v[i][k]);
      }
    }
    cout << j << endl;
    for (i = 0; i < j; ++i) {
      cout << str[i] << " " << (int)v2[i].size() << " ";
      for (k = 0; k < v2[i].size(); ++k) cout << v2[i][k] << " ";
      cout << endl;
    }
  }
  return 0;
}
