#include <bits/stdc++.h>
using namespace std;
map<string, long long int> mymap;
map<long long int, string> map2;
vector<set<string> > v(1005), ans(1005);
set<string> myset;
bool myfind(string s1, string s2) {
  if (s2.size() > s1.size()) return false;
  int rr = s1.size() - 1;
  for (int i = s2.size() - 1; i >= 0; i--) {
    if (s2[i] != s1[rr--]) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string str, s1;
  long long int n, m, val, c = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> str >> m;
    if (myset.find(str) != myset.end()) {
      val = mymap[str];
    } else {
      myset.insert(str);
      mymap[str] = c;
      val = c;
      map2[c] = str;
      c++;
    }
    for (int j = 0; j < m; j++) {
      cin >> s1;
      v[val].insert(s1);
    }
  }
  for (int i = 0; i < c; i++) {
    for (set<string>::iterator it = v[i].begin(); it != v[i].end(); it++)
      ans[i].insert(*it);
  }
  for (int i = 0; i < c; i++) {
    for (set<string>::iterator it = v[i].begin(); it != v[i].end(); it++) {
      if (it == v[i].end()) break;
      string curr = *it;
      for (set<string>::iterator itt = v[i].begin(); itt != v[i].end(); itt++) {
        string adi = *itt;
        if (myfind(adi, curr) && adi != curr) {
          set<string> pp = ans[i];
          ans[i].clear();
          pp.erase(curr);
          for (set<string>::iterator qq = pp.begin(); qq != pp.end(); qq++)
            ans[i].insert(*qq);
          break;
        }
      }
    }
  }
  cout << c << endl;
  for (int i = 0; i < c; i++) {
    cout << map2[i] << " " << ans[i].size() << " ";
    for (set<string>::iterator it = ans[i].begin(); it != ans[i].end(); it++) {
      cout << *it << " ";
    }
    cout << endl;
  }
  return 0;
}
