#include <bits/stdc++.h>
using namespace std;
bool checksuffix(string a, string b) {
  int an = (int)a.size();
  ;
  int bn = (int)b.size();
  ;
  string x = "";
  for (int i = bn - an; i < bn; i++) {
    x += b[i];
  }
  if (x == a) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  int n, q;
  cin >> n;
  map<string, set<string>> m;
  string name;
  string num;
  for (int i = 0; i < n; i++) {
    cin >> name >> q;
    for (int j = 0; j < q; j++) {
      cin >> num;
      m[name].insert(num);
    }
  }
  bool ok;
  map<string, set<string>> ans;
  set<string> v;
  for (auto i : m) {
    v.clear();
    for (auto j : i.second) {
      ok = false;
      for (auto k : i.second) {
        if ((int)j.size() < (int)k.size()) {
          ok = checksuffix(j, k);
          if (ok) {
            break;
          }
        }
      }
      if (!ok) {
        v.insert(j);
      }
    }
    ans[i.first] = v;
  }
  cout << (int)ans.size() << "\n";
  for (auto i : ans) {
    cout << i.first << " ";
    cout << (int)i.second.size() << " ";
    for (auto j : i.second) {
      cout << j << " ";
    }
    cout << "\n";
  }
  return 0;
}
