#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= M;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % M;
    a = a * a % M;
  }
  return res % M;
}
const long long N = 1e5;
int main() {
  int n;
  cin >> n;
  map<string, int> m;
  int c = 0;
  set<string> st[21], st1[21];
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    if (m.count(s))
      ;
    else
      m[s] = c++;
    int nn;
    cin >> nn;
    for (int j = 0; j < nn; ++j) {
      string ss;
      cin >> ss;
      st[m[s]].insert(ss);
    }
  }
  for (int i = 0; i < c; ++i) {
    for (set<string>::iterator it = st[i].begin(); it != st[i].end(); ++it) {
      bool flag = 0;
      for (set<string>::iterator it1 = st[i].begin(); it1 != st[i].end();
           ++it1) {
        if (*it != *it1) {
          string s1 = *it, s2 = *it1;
          if (s1.size() <= s2.size()) {
            int k = s2.size() - s1.size();
            int j = 0;
            for (; k < s2.size(); ++k) {
              if (s2[k] == s1[j])
                j++;
              else
                break;
            }
            if (j == s1.size()) flag = 1;
          }
        }
      }
      if (flag == 0) st1[i].insert(*it);
    }
  }
  cout << c << endl;
  for (map<string, int>::iterator it = m.begin(); it != m.end(); ++it) {
    cout << it->first << " " << st1[it->second].size() << " ";
    for (set<string>::iterator it1 = st1[it->second].begin();
         it1 != st1[it->second].end(); ++it1)
      cout << *it1 << " ";
    cout << endl;
  }
  return 0;
}
