#include <bits/stdc++.h>
using namespace std;
map<string, set<string>> mp;
int main() {
  int n;
  cin >> n;
  string name;
  int x;
  string num;
  for (int i = 0; i < n; i++) {
    cin >> name;
    cin >> x;
    for (int i = 0; i < x; i++) {
      cin >> num;
      mp[name].insert(num);
    }
  }
  cout << mp.size() << endl;
  for (map<string, set<string>>::iterator it = mp.begin(); it != mp.end();
       ++it) {
    cout << it->first << " ";
    vector<string> temp;
    for (set<string>::iterator s1 = mp[it->first].begin();
         s1 != mp[it->first].end(); ++s1) {
      bool needsdeleted = false;
      for (set<string>::iterator s2 = mp[it->first].begin();
           s2 != mp[it->first].end(); ++s2) {
        if (s1 != s2) {
          string string1 = *s1;
          string string2 = *s2;
          int sz1 = string1.length();
          int sz2 = string2.length();
          if (sz1 < sz2) {
            needsdeleted = true;
            int j = string2.length() - 1;
            for (int i = string1.length() - 1; i >= 0; i--) {
              if (string1[i] != string2[j]) needsdeleted = false;
              j--;
            }
            if (needsdeleted) break;
          }
        }
      }
      if (!needsdeleted) temp.push_back(*s1);
    }
    cout << temp.size() << " ";
    for (int i = 0; i < temp.size(); i++) cout << temp[i] << " ";
    cout << endl;
  }
}
