#include <bits/stdc++.h>
using namespace std;
bool brisati(string a, string b, int duzina) {
  for (int i = duzina, j = 0; i < a.length(); i++, j++) {
    if (a[i] != b[j]) return 0;
  }
  return 1;
}
int main() {
  vector<string> imena;
  map<string, bool> imenabilo;
  int n;
  cin >> n;
  string s;
  map<string, vector<string>> v;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (imenabilo[s] == 0) {
      imena.push_back(s);
      imenabilo[s] = 1;
    }
    int k;
    cin >> k;
    for (int i = 0; i < k; i++) {
      string num;
      cin >> num;
      v[s].push_back(num);
    }
  }
  for (int i = 0; i < imena.size(); i++) {
  }
  map<string, int> minusi;
  for (int i = 0; i < imena.size(); i++) {
    for (int j = 0; j < v[imena[i]].size(); j++) {
      for (int k = j + 1; k < v[imena[i]].size(); k++) {
        if (v[imena[i]][j] != "_" && v[imena[i]][j] != "_") {
          if (v[imena[i]][j].length() >= v[imena[i]][k].length()) {
            if (brisati(v[imena[i]][j], v[imena[i]][k],
                        v[imena[i]][j].size() - v[imena[i]][k].size())) {
              v[imena[i]][k] = "_";
              minusi[imena[i]]++;
            }
          } else {
            if (brisati(v[imena[i]][k], v[imena[i]][j],
                        v[imena[i]][k].size() - v[imena[i]][j].size())) {
              v[imena[i]][j] = "_";
              minusi[imena[i]]++;
            }
          }
        }
      }
    }
  }
  cout << imena.size() << "\n";
  for (int i = 0; i < imena.size(); i++) {
    cout << imena[i] << " " << v[imena[i]].size() - minusi[imena[i]] << " ";
    for (int j = 0; j < v[imena[i]].size(); j++) {
      if (v[imena[i]][j] != "_") cout << v[imena[i]][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
