#include <bits/stdc++.h>
using namespace std;
inline bool xcheck(string &a, string &b) {
  for (auto i = b.rbegin(), j = a.rbegin(); i != b.rend() && j != a.rend();
       i++, j++) {
    if (*i != *j) return true;
  }
  return false;
}
int main() {
  int t, tc;
  string name, pn;
  map<string, vector<string> > book;
  bool erc;
  cin >> t;
  while (t--) {
    cin >> name >> tc;
    while (tc--) {
      cin >> pn;
      book[name].push_back(pn);
    }
  }
  for (auto i = book.begin(); i != book.end(); i++) {
    auto buf = i->second;
    for (auto j = buf.begin(); j != buf.end();) {
      erc = false;
      for (auto k = buf.begin(); k != buf.end(); k++) {
        if (j == k) continue;
        if ((*j).length() > (*k).length()) continue;
        if (!xcheck(*j, *k)) {
          erc = true;
          break;
        }
      }
      if (erc) {
        j = buf.erase(j);
      } else {
        j++;
      }
    }
    i->second = buf;
  }
  cout << book.size() << endl;
  for (auto i : book) {
    cout << i.first << " " << i.second.size();
    for (auto j : i.second) {
      cout << " " << j;
    }
    cout << endl;
  }
  getchar();
  getchar();
  return 0;
}
