#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
bool sortinrev(const pair<long long int, long long int> &a,
               const pair<long long int, long long int> &b) {
  return (a.first > b.first);
}
long long int A[1000000];
long long int B[1000000];
long long int C[1000000];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  map<string, long long int> mp;
  set<string> st;
  vector<string> v[30];
  long long int n, x = 1;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (!st.count(s)) st.insert(s), mp[s] = x++;
    long long int a;
    cin >> a;
    for (long long int j = 0; j < a; j++) {
      string ss;
      cin >> ss;
      v[mp[s]].push_back(ss);
      ss.clear();
    }
    s.clear();
  }
  cout << st.size() << endl;
  set<string>::iterator it;
  for (it = st.begin(); it != st.end(); it++) {
    vector<string> help;
    sort(v[mp[*it]].begin(), v[mp[*it]].end());
    v[mp[*it]].resize(unique(v[mp[*it]].begin(), v[mp[*it]].end()) -
                      v[mp[*it]].begin());
    help.push_back(*it);
    for (long long int i = 0; i < v[mp[*it]].size(); i++) {
      bool check = true;
      for (long long int j = 0; j < v[mp[*it]].size(); j++) {
        if (v[mp[*it]][i] != v[mp[*it]][j] &&
            v[mp[*it]][i].size() < v[mp[*it]][j].size()) {
          bool c = true;
          for (long long int k = v[mp[*it]][i].size() - 1,
                             m = v[mp[*it]][j].size() - 1;
               k >= 0; k--, m--) {
            if (v[mp[*it]][i][k] != v[mp[*it]][j][m]) {
              c = false;
              break;
            }
          }
          if (c) {
            check = false;
            break;
          }
        }
      }
      if (check) help.push_back(v[mp[*it]][i]);
    }
    cout << help[0] << " ";
    cout << help.size() - 1 << " ";
    for (long long int i = 1; i < help.size(); i++) cout << help[i] << " ";
    cout << endl;
    help.clear();
  }
  return 0;
}
