#include <bits/stdc++.h>
int main() {
  size_t n = 0;
  std::cin >> n;
  std::unordered_map<std::string, std::unordered_set<std::string>> phone_cache;
  for (size_t t = 0; t < n; t++) {
    std::string name;
    std::cin >> name;
    {
      auto it = phone_cache.find(name);
      if (it == phone_cache.end()) {
        phone_cache.emplace(name, std::unordered_set<std::string>{});
      }
    }
    std::unordered_set<std::string>& phone_cache_local =
        phone_cache.find(name)->second;
    std::size_t np = 0;
    std::cin >> np;
    for (size_t i = 0; i < np; i++) {
      std::string phone;
      std::cin >> phone;
      if (phone_cache_local.find(phone) == phone_cache_local.end()) {
        phone_cache_local.emplace(phone);
      }
    }
  }
  std::unordered_map<std::string, std::vector<std::string>> data;
  for (const auto it : phone_cache) {
    const auto name = it.first;
    const auto its = data.emplace(name, std::vector<std::string>{});
    auto& data_local = its.first->second;
    const auto& phones = it.second;
    std::unordered_set<std::string> suffix_cache;
    for (const auto& phone : phones) {
      for (size_t i = 1; i < phone.length(); i++) {
        suffix_cache.emplace(phone.substr(i));
      }
    }
    for (const auto& phone : phones) {
      if (suffix_cache.find(phone) == suffix_cache.end()) {
        data_local.push_back(phone);
      }
    }
  }
  std::cout << data.size() << '\n';
  for (const auto it : data) {
    std::cout << it.first << ' ';
    std::cout << it.second.size();
    for (const auto& phone : it.second) {
      std::cout << ' ' << phone;
    }
    std::cout << '\n';
  }
  return 0;
}
