#include <bits/stdc++.h>
using namespace std;
bool isSuffix(string &s1, string &s2) {
  int len1 = s1.length(), len2 = s2.length();
  if (len2 > len1) return false;
  for (int i = len1 - 1; i >= 0; --i) {
    if (len2 + i - len1 == -1) break;
    if (s1[i] != s2[len2 + i - len1]) return false;
  }
  return true;
}
bool isFoundBefore(vector<string> &vec, string &s) {
  int n = vec.size();
  for (int i = 0; i < n; ++i) {
    if (isSuffix(vec[i], s)) return true;
    if (isSuffix(s, vec[i])) {
      swap(s, vec[i]);
      return true;
    }
  }
  return false;
}
int main() {
  int n, m;
  map<string, vector<string>> phoneBook;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string name, num;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> name;
    cin >> m;
    for (int j = 0; j < m; ++j) {
      cin >> num;
      if (!isFoundBefore(phoneBook[name], num))
        phoneBook[name].emplace_back(num);
    }
  }
  cout << phoneBook.size() << endl;
  for (auto i = phoneBook.begin(); i != phoneBook.end(); ++i) {
    cout << i->first << " " << i->second.size() << " ";
    for (int j = 0; j < i->second.size(); ++j) {
      cout << i->second[j] << " ";
    }
    cout << endl;
  }
  return 0;
}
