#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, c = 0;
  string s, p;
  map<string, int> name;
  vector<set<string> > phone;
  vector<vector<bool> > write;
  vector<vector<string> > write2;
  phone.assign(20, set<string>());
  write.assign(20, vector<bool>());
  write2.assign(20, vector<string>());
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s >> k;
    if (name.find(s) == name.end()) name[s] = c++;
    while (k--) {
      cin >> p;
      phone[name[s]].insert(p);
    }
  }
  for (int i = 0; i < phone.size(); i++) {
    int w = 0;
    for (set<string>::iterator j = phone[i].begin(); j != phone[i].end(); ++j) {
      s = *j;
      write[i].push_back(true);
      write2[i].push_back(s);
      for (set<string>::iterator k = phone[i].begin(); k != phone[i].end();
           ++k) {
        string t = *k;
        if (s == t) continue;
        if (t.length() < s.length()) continue;
        if (t.substr(t.length() - s.length(), t.length()) == s) {
          write[i][w] = false;
        }
      }
      w++;
    }
  }
  int d = 0;
  for (int i = 0; i < write.size(); i++) {
    c = 0;
    for (int j = 0; j < write[i].size(); j++)
      if (write[i][j]) c++;
    if (c) d++;
  }
  cout << d << endl;
  for (int i = 0; i < phone.size(); i++) {
    if (phone[i].empty()) continue;
    for (map<string, int>::iterator it = name.begin(); it != name.end(); ++it) {
      if (it->second == i) {
        cout << it->first << " ";
        break;
      }
    }
    c = 0;
    for (int j = 0; j < write[i].size(); j++)
      if (write[i][j]) c++;
    cout << c << " ";
    for (int j = 0; j < write[i].size(); j++) {
      if (write[i][j]) cout << write2[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
