#include <bits/stdc++.h>
using namespace std;
void fscpp() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fscpp();
  map<string, set<string>> f;
  int N;
  cin >> N;
  string s;
  for (int n = 0; n < N; n++) {
    cin >> s;
    int cn = 0;
    cin >> cn;
    string fn;
    for (int x = 0; x < cn; x++) {
      cin >> fn;
      f[s].insert(fn);
    }
  }
  map<string, vector<string>> r;
  for (auto nm : f) {
    vector<string> ret;
    for (string y : nm.second) {
      ret.push_back(y);
    }
    for (int x = 0; x < ret.size(); x++) {
      bool sf = false;
      for (int y = 0; y < ret.size(); y++) {
        if (x == y) continue;
        if (ret[y].length() < ret[x].length()) continue;
        bool issf = true;
        int bg = ret[y].length() - ret[x].length();
        for (int z = 0; z < ret[x].size(); z++) {
          if (ret[x][z] != ret[y][z + bg]) {
            issf = false;
            break;
          }
        }
        if (issf) {
          sf = true;
          break;
        }
      }
      if (!sf) {
        r[nm.first].push_back(ret[x]);
      }
    }
  }
  cout << r.size() << endl;
  for (auto x : r) {
    cout << x.first << " ";
    cout << x.second.size();
    for (string y : x.second) {
      cout << " " << y;
    }
    cout << endl;
  }
  return 0;
}
