#include <bits/stdc++.h>
using namespace std;
long long n, id;
string person, phone;
int main() {
  map<string, map<string, bool> > people;
  map<string, map<string, bool> > output;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> person >> id;
    for (int j = 1; j <= id; j++) {
      cin >> phone;
      output[person][phone] = true;
      people[person][phone] = true;
    }
  }
  map<string, bool>::iterator it;
  for (auto& personIT : people) {
    string person = personIT.first;
    for (auto& phoneIT : personIT.second) {
      string suf, phone = phoneIT.first;
      for (int j = 1; j < phone.size(); j++) {
        suf = phone.substr(j, phone.size());
        if (output[person].count(suf) > 0) {
          it = output[person].find(suf);
          output[person].erase(it);
        }
      }
    }
  }
  cout << output.size() << "\n";
  for (auto& personIT : output) {
    string person = personIT.first;
    cout << person << " ";
    cout << personIT.second.size() << " ";
    for (auto& phoneIT : personIT.second) {
      cout << phoneIT.first << " ";
    }
    cout << "\n";
  }
  return 0;
}
