#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
int main() {
  int n;
  cin >> n;
  map<string, vector<string>> ans;
  while (n--) {
    string second;
    cin >> second;
    int a;
    cin >> a;
    while (a--) {
      string p;
      cin >> p;
      ans[second].push_back(p);
    }
  }
  cout << ans.size() << '\n';
  for (auto ent : ans) {
    set<string> now;
    string key = ent.first;
    for (int i = 0; i < ans[key].size(); i++) {
      string p = ans[key][i];
      bool nsuf = true;
      for (int j = 0; j < ans[key].size(); j++) {
        string q = ans[key][j];
        if (q.size() <= p.size()) {
          continue;
        }
        for (int k = 0; k < p.size(); k++) {
          if (q[q.size() - k - 1] != p[p.size() - k - 1]) break;
          if (k == p.size() - 1) nsuf = false;
        }
      }
      if (nsuf) now.insert(p);
    }
    cout << ent.first << " " << now.size() << " ";
    for (auto z : now) cout << z << " ";
    cout << '\n';
  }
  exit(0);
}
