#include <bits/stdc++.h>
using namespace std;
map<string, vector<string> > Ag;
string Name, Tel;
vector<string> Ans;
bool cmp(string A, string B) { return A.size() < B.size(); }
bool Test(string A, string B) {
  int i = A.size() - 1, j = B.size() - 1;
  while (i >= 0 && A[i] == B[j]) --i, --j;
  if (i == -1) return 1;
  return 0;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int no;
    cin >> Name >> no;
    for (int i = 1; i <= no; ++i) {
      cin >> Tel;
      Ag[Name].push_back(Tel);
    }
  }
  cout << Ag.size() << "\n";
  for (auto Name : Ag) {
    Ans.resize(0);
    vector<string> aux = Name.second;
    sort(aux.begin(), aux.end(), cmp);
    int len = aux.size();
    for (int i = 0; i < len; ++i) {
      bool ok = 1;
      for (int j = i + 1; j < len; ++j) {
        if (Test(aux[i], aux[j]) == 1) {
          ok = 0;
          break;
        }
      }
      if (ok == 1) Ans.push_back(aux[i]);
    }
    cout << Name.first << " " << Ans.size() << " ";
    for (int i = 0; i < Ans.size(); ++i) cout << Ans[i] << " ";
    cout << "\n";
  }
}
