#include <bits/stdc++.h>
using namespace std;
int n, z, i;
string a, b;
map<string, set<string>> m;
int main() {
  cin >> n;
  while (n--) {
    cin >> a >> z;
    while (z--) cin >> b, m[a].insert(b);
  }
  for (auto &i : m) {
    while (1729) {
      int orig_size = i.second.size();
      for (auto &j : i.second) {
        bool well = false;
        for (auto &k : i.second) {
          if (k == j or j.size() > k.size()) continue;
          if (k.substr(k.size() - j.size()) == j) {
            i.second.erase(j);
            well = true;
            break;
          }
        }
        if (well) break;
      }
      if (i.second.size() == orig_size) break;
    }
  }
  cout << m.size() << "\n";
  for (auto i : m) {
    cout << i.first << " " << i.second.size() << " ";
    for (auto j : i.second) cout << j << " ";
    cout << "\n";
  }
}
