#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long q = 1;
  while (q--) {
    int n, f;
    cin >> n;
    string k, l;
    map<string, set<string>> mp;
    for (int i = 0; i < n; i++) {
      cin >> k >> f;
      for (int j = 0; j < f; j++) {
        cin >> l;
        mp[k].insert(l);
      }
    }
    cout << mp.size() << endl;
    for (auto it = mp.begin(); it != mp.end(); it++) {
      cout << it->first << " ";
      vector<string> v;
      for (auto i = it->second.begin(); i != it->second.end(); i++) {
        v.push_back(*i);
      }
      int z = v.size();
      for (int i = 0; i < v.size(); i++) {
        if (v[i] == "ja re tu") continue;
        for (int j = 0; j < v.size(); j++) {
          if (j == i or v[j] == "ja re tu") continue;
          if (v[i].size() <= v[j].size()) {
            bool ok(1);
            for (int p = 1; p <= v[i].size(); p++) {
              if (v[i][v[i].size() - p] != v[j][v[j].size() - p]) {
                ok = 0;
                break;
              }
            }
            if (ok) {
              z--;
              v[i] = "ja re tu";
              break;
            }
          } else {
            bool ok(1);
            for (int p = 1; p <= v[j].size(); p++) {
              if (v[i][v[i].size() - p] != v[j][v[j].size() - p]) {
                ok = 0;
                break;
              }
            }
            if (ok) {
              z--;
              v[j] = "ja re tu";
            }
          }
        }
      }
      cout << z << " ";
      for (int i = 0; i < v.size(); i++) {
        if (v[i] == "ja re tu") continue;
        cout << v[i] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
