#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    map<string, set<string> > m, mTemp, res;
    string str, x;
    int k;
    for (int i = 0; i < n; ++i) {
      cin >> str >> k;
      for (int j = 0; j < k; ++j) {
        cin >> x;
        m[str].insert(x);
        mTemp[str].insert(x);
      }
    }
    bool flag;
    for (map<string, set<string> >::iterator it1 = m.begin(); it1 != m.end();
         ++it1) {
      for (map<string, set<string> >::iterator it2 = mTemp.begin();
           it2 != mTemp.end(); ++it2) {
        if (it1->first == it2->first) {
          for (set<string>::iterator it3 = it1->second.begin();
               it3 != it1->second.end(); ++it3) {
            flag = true;
            for (set<string>::iterator it4 = it2->second.begin();
                 it4 != it2->second.end(); ++it4) {
              if ((*it3) == (*it4))
                continue;
              else if ((*it3).length() < (*it4).length() &&
                       ((*it3) ==
                        (*it4).substr((*it4).length() - (*it3).length()))) {
                flag = false;
                break;
              }
            }
            if (flag) res[it1->first].insert(*it3);
          }
        }
      }
    }
    cout << res.size() << "\n";
    for (map<string, set<string> >::iterator it = res.begin(); it != res.end();
         ++it) {
      cout << it->first << " " << it->second.size() << " ";
      for (set<string>::iterator it1 = it->second.begin();
           it1 != it->second.end(); ++it1)
        cout << *it1 << " ";
      cout << endl;
    }
  }
}
