#include <bits/stdc++.h>
using namespace std;
map<string, vector<string> > a;
int n;
void f() {
  for (auto e : a) {
    vector<string> ls = e.second;
    for (int k = 0; k < 20; k++) {
      for (int i = 0; i < ls.size(); i++) {
        for (int j = 0; j < ls.size(); j++) {
          if ((ls[i].rfind(ls[j]) == (ls[i].size() - ls[j].size())) && i != j &&
              ls[i].rfind(ls[j]) != string::npos) {
            ls.erase(ls.begin() + j);
          }
        }
      }
    }
    a[e.first] = ls;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string name;
    int amount;
    cin >> name;
    cin >> amount;
    for (int j = 0; j < amount; j++) {
      string b;
      cin >> b;
      a[name].push_back(b);
    }
  }
  f();
  cout << a.size() << endl;
  for (auto e : a) {
    cout << e.first << " " << e.second.size() << " ";
    for (auto num : e.second) {
      cout << num << " ";
    }
    cout << endl;
  }
}
