#include <bits/stdc++.h>
using namespace std;
vector<string> g[10010];
map<string, int> mp;
string idx[10010];
int n, sz;
string s;
string tmp[10010];
bool judge(string x, string y) {
  int lx = x.length(), ly = y.length();
  if (lx >= ly) return 0;
  for (int i = 0; i < lx; ++i) {
    if (x[lx - 1 - i] != y[ly - 1 - i]) return 0;
  }
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    cin >> s;
    if (!mp.count(s)) mp[s] = ++sz;
    int nam = mp[s];
    idx[nam] = s;
    int m;
    scanf("%d", &m);
    while (m--) {
      cin >> s;
      g[nam].push_back(s);
    }
  }
  printf("%d\n", sz);
  for (int i = 1; i <= sz; ++i) {
    cout << idx[i] << " ";
    int ssz = (int)g[i].size();
    int num = 0;
    for (int j = 0; j < ssz; ++j) {
      bool ok = 1;
      for (int k = 0; k < ssz; ++k)
        if (j != k && judge(g[i][j], g[i][k])) {
          ok = 0;
          break;
        }
      if (ok) {
        bool fk = 1;
        for (int k = 0; k < num; ++k) {
          if (tmp[k] == g[i][j]) {
            fk = 0;
            break;
          }
        }
        if (fk) tmp[num++] = g[i][j];
      }
    }
    printf("%d", num);
    for (int j = 0; j < num; ++j) cout << " " << tmp[j];
    puts("");
  }
  return 0;
}
