#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  map<string, set<string> > mp;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    int m;
    cin >> m;
    for (int j = 0; j < m; j++) {
      string num;
      cin >> num;
      mp[s].insert(num);
    }
  }
  map<string, set<string> > ans;
  for (map<string, set<string> >::iterator it = mp.begin(); it != mp.end();
       ++it) {
    set<string> ss = (it->second);
    string s = it->first;
    map<string, bool> vis;
    for (set<string>::iterator i = ss.begin(); i != ss.end(); i++) {
      bool f = 0;
      set<string>::iterator j = ss.begin();
      for (; j != ss.end(); j++) {
        if (i == j) continue;
        string s1 = *i;
        string s2 = *j;
        if (s2.size() >= s1.size()) {
          if (s2.substr(s2.size() - s1.size()) == s1) {
            vis[s1] = 1;
          }
        }
      }
    }
    for (set<string>::iterator i = ss.begin(); i != ss.end(); i++)
      if (!vis[*i]) ans[s].insert(*i);
  }
  cout << ans.size() << endl;
  for (map<string, set<string> >::iterator it = ans.begin(); it != ans.end();
       ++it) {
    set<string> ss = (it->second);
    string s = it->first;
    cout << it->first << " ";
    cout << ss.size() << " ";
    for (set<string>::iterator i = ss.begin(); i != ss.end(); ++i) {
      cout << *i << " ";
    }
    cout << endl;
  }
  return 0;
}
