#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> Id;
int GetId(string &name) {
  static int tot = 0;
  if (!Id.count(name)) {
    Id[name] = ++tot;
    return tot;
  }
  return Id[name];
}
vector<string> entry[30];
bool IsSuffix(string &a, string &b) {
  int na = a.length(), nb = b.length();
  if (na > nb) return false;
  for (int i = 0; i < na; ++i)
    if (a[i] != b[i]) return false;
  return true;
}
vector<string> seg;
void Print(string name, int id) {
  seg.clear();
  sort(entry[id].begin(), entry[id].end());
  seg.push_back(entry[id][entry[id].size() - 1]);
  for (int i = entry[id].size() - 2; i >= 0; --i) {
    if (!IsSuffix(entry[id][i], entry[id][i + 1])) seg.push_back(entry[id][i]);
  }
  cout << name;
  cout << " " << seg.size();
  for (int i = 0; i < seg.size(); ++i) {
    reverse(seg[i].begin(), seg[i].end());
    cout << " " << seg[i];
  }
  cout << "\n";
}
int main() {
  int n, m;
  string tmp;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> tmp;
    int id = GetId(tmp);
    cin >> m;
    for (int k = 1; k <= m; ++k) {
      cin >> tmp;
      reverse(tmp.begin(), tmp.end());
      entry[id].push_back(tmp);
    }
  }
  cout << Id.size() << "\n";
  for (auto it : Id) {
    Print(it.first, it.second);
  }
  return 0;
}
