#include <bits/stdc++.h>
using namespace std;
map<string, int> M;
vector<string> N;
vector<vector<string> > num;
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string name;
    int nn, id = 0;
    vector<string> tmp;
    cin >> name >> nn;
    if (M.find(name) != M.end())
      id = M[name], tmp = num[id];
    else
      id = M[name] = num.size(), N.push_back(name);
    for (int ii = 0; ii < nn; ii++) {
      string input;
      int old = 0;
      cin >> input;
      for (int j = 0; j < tmp.size() && !old; j++) {
        string B, S;
        B = input, S = tmp[j];
        if (S.size() > B.size()) swap(S, B);
        if (B.substr(B.size() - S.size()) == S) old = 1, tmp[j] = B;
      }
      if (!old) tmp.push_back(input);
    }
    if (id != num.size())
      num[id] = tmp;
    else
      num.push_back(tmp);
  }
  cout << num.size() << '\n';
  for (int i = 0; i < num.size(); i++) {
    cout << N[i] << ' ' << num[i].size();
    for (int j = 0; j < num[i].size(); j++) cout << ' ' << num[i][j];
    cout << '\n';
  }
  return 0;
}
