#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, i, j, k;
  cin >> n;
  map<string, set<string> > myMap;
  for (i = 0; i < n; i++) {
    string second;
    cin >> second;
    int a;
    cin >> a;
    for (j = 0; j < a; j++) {
      string aa;
      cin >> aa;
      myMap[second].insert(aa);
    }
  }
  cout << myMap.size() << endl;
  for (auto it : myMap) {
    vector<string> second;
    for (auto j : it.second) second.push_back(j);
    set<string> aa;
    for (j = 0; j < second.size(); j++) {
      int flag = 0;
      for (k = 0; k < second.size(); k++) {
        if (j != k) {
          if (second[k].size() > second[j].size()) {
            if (second[j] ==
                second[k].substr(second[k].size() - second[j].size()))
              flag = 1;
          }
        }
      }
      if (!flag) aa.insert(second[j]);
    }
    cout << it.first << " " << aa.size() << " ";
    for (auto g : aa) cout << g << " ";
    cout << endl;
  }
}
