#include <bits/stdc++.h>
using namespace std;
int n, a, b, pre = 0;
struct Yukari {
  int tot;
  string ans[210];
} an;
string ch, pr;
map<string, Yukari> mmp;
map<string, Yukari>::iterator it;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    cin >> ch;
    if (!mmp.count(ch)) {
      pre++;
      mmp[ch].tot = 0;
    }
    scanf("%d", &n);
    int che = 0;
    for (int i = 1; i <= n; i++) {
      cin >> pr;
      che = 0;
      a = pr.length();
      for (int j = 1; j <= mmp[ch].tot; j++)
        if (!che) {
          b = mmp[ch].ans[j].length();
          if (a > b) {
            int check = 0;
            for (int k = 0; k < b; k++) {
              if (pr[a - b + k] != mmp[ch].ans[j][k]) {
                check = 1;
                break;
              }
            }
            if (!check) {
              mmp[ch].ans[j] = pr;
              che = 1;
            }
          } else {
            int check = 0;
            for (int k = 0; k < a; k++) {
              if (pr[k] != mmp[ch].ans[j][b - a + k]) {
                check = 1;
                break;
              }
            }
            if (!check) {
              che = 1;
              break;
            }
          }
        }
      if (!che) mmp[ch].ans[++mmp[ch].tot] = pr;
    }
  }
  printf("%d\n", pre);
  for (it = mmp.begin(); it != mmp.end(); it++) {
    an = it->second;
    cout << it->first;
    printf(" %d ", an.tot);
    for (int i = 1; i <= an.tot; i++) cout << an.ans[i] << " ";
    puts("");
  }
}
