#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void upd1(T& a, T b) {
  a > b ? a = b : 0;
}
template <class T>
inline void upd2(T& a, T b) {
  a < b ? a = b : 0;
}
struct ano {
  operator long long() {
    long long x = 0, y = 0, c = getchar();
    while (c < 48) y = c == 45, c = getchar();
    while (c > 47) x = x * 10 + c - 48, c = getchar();
    return y ? -x : x;
  }
} buf;
int main() {
  int n = buf;
  map<string, set<string>> f;
  while (n--) {
    int k;
    string name, s;
    cin >> name >> k;
    while (k--) cin >> s, f[name].insert(s);
  }
  cout << f.size() << endl;
  for (auto& a : f) {
    set<string> t;
    vector<string> b;
    for (auto s : a.second)
      for (int i = 1; i < s.size(); ++i) t.insert(s.substr(i));
    for (auto s : a.second)
      if (!t.count(s)) b.push_back(s);
    cout << a.first << " " << b.size() << " ";
    for (auto s : b) cout << s << " ";
    cout << endl;
  }
}
