#include <bits/stdc++.h>
using namespace std;
bool isSuffix(string phoneNumber, set<string> phoneNumbers) {
  for (auto c : phoneNumbers) {
    if (c != phoneNumber && c.length() > phoneNumber.length()) {
      bool is = 1;
      for (int i = phoneNumber.length() - 1, j = c.length() - 1; i >= 0;
           --i, --j) {
        if (phoneNumber[i] != c[j]) {
          is = 0;
          break;
        }
      }
      if (is) {
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  int n;
  cin >> n;
  string name;
  map<string, set<string>> phoneDirectory;
  for (int i = 0; i < n; ++i) {
    cin >> name;
    int k;
    cin >> k;
    string phoneNumber;
    for (int j = 0; j < k; ++j) {
      cin >> phoneNumber;
      phoneDirectory[name].insert(phoneNumber);
    }
  }
  map<string, vector<string>> toRemove;
  for (auto c : phoneDirectory) {
    for (auto c2 : c.second) {
      bool k = isSuffix(c2, c.second);
      if (k) {
        toRemove[c.first].push_back(c2);
      }
    }
  }
  for (auto c : toRemove) {
    for (auto c2 : c.second) phoneDirectory[c.first].erase(c2);
  }
  cout << phoneDirectory.size() << "\n";
  for (auto c : phoneDirectory) {
    cout << c.first << " " << c.second.size();
    for (auto c2 : c.second) {
      cout << " " << c2;
    }
    cout << "\n";
  }
  return 0;
}
