#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
const double pi = 2 * acos(0.0);
const int N = 2e3 + 5;
struct cmp {
  bool operator()(const string& a, const string& b) {
    if (int((a).size()) == int((b).size())) return a > b;
    return int((a).size()) > int((b).size());
  }
};
int main() {
  map<string, set<string, cmp> > mp;
  int n;
  scanf("%d", &(n));
  for (int i = 0; i < n; i++) {
    string name;
    cin >> name;
    int m;
    scanf("%d", &(m));
    for (int j = 0; j < m; j++) {
      string num;
      cin >> num;
      mp[name].insert(num);
    }
  }
  for (auto& record : mp) {
    for (auto it1 = record.second.begin(); it1 != record.second.end(); it1++) {
      string num1 = *it1;
      auto temp = ++it1;
      it1--;
      for (auto it2 = temp; it2 != record.second.end();) {
        string num2 = *it2;
        bool isSuffix = true;
        int j = int((num1).size()) - 1;
        for (int i = int((num2).size()) - 1; i >= 0 && isSuffix; i--) {
          if (num2[i] != num1[j--]) isSuffix = false;
        }
        if (isSuffix)
          it2 = record.second.erase(it2);
        else
          it2++;
      }
    }
  }
  printf("%d\n", int((mp).size()));
  for (auto& record : mp) {
    printf("%s %d ", record.first.c_str(), record.second.size());
    for (auto& num : record.second) {
      printf("%s ", num.c_str());
    }
    printf("\n");
  }
  return 0;
}
