#include <bits/stdc++.h>
using namespace std;
int n;
map<string, int> id;
map<string, int>::iterator it;
vector<string> ans[30];
char s[100];
vector<string> v[30];
bool f(string &a, string &b) {
  if (a.size() > b.size()) return false;
  int dif = (int)(b.size() - a.size());
  for (int i = 0; i < (int)a.size(); ++i) {
    if (i + dif >= b.size()) return false;
    if (a[i] != b[i + dif]) return false;
  }
  return true;
}
int cnt = 1;
int main() {
  scanf("%d", &n);
  while (n--) {
    int k;
    scanf(" %s %d", s, &k);
    string ss = (string)s;
    if (!id[ss]) id[ss] = cnt++;
    int i = id[ss];
    while (k--) {
      scanf(" %s", s);
      string s2 = (string)s;
      v[i].push_back(s2);
    }
  }
  for (int i = 1; i <= (int)id.size(); ++i) {
    for (int j = 0; j < v[i].size(); ++j) {
      for (int k = 0; k < v[i].size(); ++k) {
        if (k == j) continue;
        if (v[i][k] == "-") continue;
        if (f(v[i][j], v[i][k])) {
          v[i][j] = "-";
          break;
        }
      }
      if (v[i][j] != "-") {
        ans[i].push_back(v[i][j]);
      }
    }
  }
  printf("%d\n", (int)id.size());
  for (it = id.begin(); it != id.end(); ++it) {
    int i = it->second;
    printf("%s %d", it->first.c_str(), (int)ans[i].size());
    for (int j = 0; j < ans[i].size(); ++j) {
      printf(" %s", ans[i][j].c_str());
    }
    printf("\n");
  }
  return 0;
}
