#include <bits/stdc++.h>
using namespace std;
map<string, set<pair<int, string>>> mp;
string a, b;
int n, x;
int main() {
  cin >> n;
  while (n--) {
    cin >> a;
    cin >> x;
    while (x--) {
      cin >> b;
      mp[a].insert({b.length(), b});
    }
  }
  cout << mp.size() << endl;
  for (auto p : mp) {
    string name = p.first;
    set<pair<int, string>> s = p.second;
    set<string> tmp;
    for (auto bb : s) {
      string b = bb.second;
      int len = bb.first;
      for (int i = 1; i <= len; i++) tmp.erase(b.substr(len - i));
      tmp.insert(b);
    }
    int k = tmp.size();
    cout << name << " " << k;
    for (auto a : tmp) {
      cout << " " << a;
    }
    cout << endl;
  }
  return 0;
}
