#include <bits/stdc++.h>
using namespace std;
vector<string> aaa;
bool fun(string s1, string s2) { return s1.size() < s2.size(); }
int main() {
  int t = 1;
  while (t--) {
    int n;
    cin >> n;
    map<string, set<string> > a;
    map<string, set<string> >::iterator it;
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      int x;
      cin >> x;
      for (int k = 0; k < x; k++) {
        string ss;
        cin >> ss;
        a[s].insert(ss);
      }
    }
    cout << a.size() << endl;
    for (it = a.begin(); it != a.end(); it++) {
      cout << (*it).first << " ";
      set<string> aa;
      set<string>::iterator w;
      aa = (*it).second;
      vector<string> aaa;
      vector<string>::iterator e, e1;
      for (w = aa.begin(); w != aa.end(); w++) aaa.push_back(*w);
      sort(aaa.begin(), aaa.end(), fun);
      for (e = aaa.begin(); e != aaa.end();) {
        string s1 = *e;
        for (e1 = e + 1; e1 != aaa.end(); e1++) {
          string s2 = *e1;
          int n2 = s2.size();
          int n1 = s1.size();
          if (s1 == s2.substr(n2 - n1, n1)) {
            aaa.erase(e);
            break;
          }
        }
        if (e1 == aaa.end()) e++;
      }
      sort(aaa.begin(), aaa.end(), fun);
      for (e = aaa.begin(); e != aaa.end();) {
        string s1 = *e;
        for (e1 = e + 1; e1 != aaa.end(); e1++) {
          string s2 = *e1;
          int n2 = s2.size();
          int n1 = s1.size();
          if (s1 == s2.substr(n2 - n1, n1)) {
            aaa.erase(e);
            break;
          }
        }
        if (e1 == aaa.end()) e++;
      }
      cout << aaa.size() << " ";
      for (int i = 0; i < aaa.size(); i++) {
        cout << aaa[i] << " ";
      }
      cout << endl;
    }
  }
}
