#include <bits/stdc++.h>
using namespace std;
int func(string a, string b) {
  if (b.length() < a.length()) {
    return 1;
  } else {
    int flag, i, j;
    flag = 0;
    for (i = b.length() - 1, j = a.length() - 1; j >= 0; j--, i--) {
      if (b[i] != a[j]) {
        flag = 1;
        break;
      }
    }
    return flag;
  }
}
int main() {
  int n, i, j, id, flag;
  id = 0;
  map<string, int> mp;
  map<int, string> m;
  cin >> n;
  set<string> s[25];
  set<string>::iterator it, it1;
  string name[25], temp, temp1, x;
  int non[25], d;
  for (i = 0; i < n; i++) {
    cin >> name[i];
    if (!mp.count(name[i])) mp[name[i]] = id++;
    d = mp[name[i]];
    m[d] = name[i];
    cin >> non[i];
    for (j = 0; j < non[i]; j++) {
      cin >> x;
      s[d].insert(x);
    }
  }
  vector<string> v[25];
  for (i = 0; i < id; i++) {
    for (it = s[i].begin(); it != s[i].end(); it++) {
      temp = "";
      temp = *it;
      flag = 0;
      for (it1 = s[i].begin(); it1 != s[i].end(); it1++) {
        if (it != it1) {
          temp1 = "";
          temp1 = *it1;
          if (func(temp, temp1) == 0) {
            flag = 1;
            break;
          }
        }
      }
      if (flag == 0) {
        v[i].push_back(temp);
      }
    }
  }
  cout << id << "\n";
  for (i = 0; i < id; i++) {
    cout << m[i] << " " << v[i].size();
    for (j = 0; j < v[i].size(); j++) cout << " " << v[i][j];
    cout << "\n";
  }
  return 0;
}
