#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  map<string, set<string> > m;
  cin >> n;
  vector<string> v;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int l;
    cin >> l;
    for (int i = 0; i < l; i++) {
      string t;
      cin >> t;
      if (m.find(s) == m.end()) {
        v.push_back(s);
      }
      m[s].insert(t);
    }
  }
  for (auto s : v)
    for (auto x : m[s]) {
      for (int i = 1; i < x.size(); i++) {
        if (m[s].find(x.substr(i, x.size())) != m[s].end()) {
          m[s].erase(x.substr(i, x.size()));
        }
      }
    }
  cout << v.size() << endl;
  ;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
    cout << m[v[i]].size() << " ";
    for (auto x : m[v[i]]) {
      cout << x << " ";
    }
    cout << endl;
  }
}
