#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<string, set<string> > mymap;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    int m;
    cin >> m;
    for (int j = 0; j < m; j++) {
      string phnNum;
      cin >> phnNum;
      set<string>& s_ref = mymap[str];
      s_ref.insert(phnNum);
    }
  }
  cout << mymap.size() << endl;
  map<string, set<string> >::iterator it;
  for (it = mymap.begin(); it != mymap.end(); ++it) {
    set<string>::iterator it2;
    int sz = mymap[it->first].size();
    int cnt = 0;
    map<string, bool> strmap;
    for (it2 = mymap[it->first].begin(); it2 != mymap[it->first].end(); ++it2)
      strmap[*it2] = true;
    for (it2 = mymap[it->first].begin(); it2 != mymap[it->first].end(); ++it2) {
      set<string>::iterator it3;
      for (it3 = mymap[it->first].begin(); it3 != mymap[it->first].end();
           ++it3) {
        if (it3 == it2) continue;
        if ((*it2).size() < (*it3).size()) continue;
        if (strmap[*it3] == false) continue;
        int beg = (*it2).size() - (*it3).size();
        int len = (*it3).size();
        string temp = (*it2).substr(beg, len);
        if (*it3 == temp) {
          strmap[*it3] = false;
          cnt++;
        }
      }
    }
    cout << it->first << " " << sz - cnt;
    for (it2 = mymap[it->first].begin(); it2 != mymap[it->first].end(); ++it2) {
      if (strmap[*it2] == true) cout << " " << *it2;
    }
    cout << endl;
  }
  return 0;
}
