#include <bits/stdc++.h>
using namespace std;
map<string, vector<string> > Map;
string s;
string s1;
int n, nr;
int f[1000];
int x;
bool sufix(string s, string s1) {
  int n = s.size();
  int n1 = s1.size();
  if (n1 < n) {
    return 0;
  }
  n--;
  n1--;
  while (n >= 0) {
    if (s[n] != s1[n1]) {
      return 0;
    }
    n--;
    n1--;
  }
  return 1;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    cin >> x;
    for (int i = 1; i <= x; i++) {
      cin >> s1;
      Map[s].push_back(s1);
    }
  }
  cout << Map.size() << '\n';
  for (auto it : Map) {
    cout << it.first << ' ';
    int x = it.second.size();
    nr = 0;
    memset(f, 0, sizeof(f));
    for (int i = 0; i < x; i++) {
      for (int j = 0; j < x; j++) {
        if (j == i) continue;
        if (f[j] == 1) continue;
        if (sufix(it.second[i], it.second[j])) {
          f[i] = 1;
        }
      }
    }
    for (int i = 0; i < x; i++) {
      if (f[i] == 0) {
        nr++;
      }
    }
    cout << nr << ' ';
    for (int i = 0; i < x; i++) {
      if (f[i] == 0) {
        cout << it.second[i] << ' ';
      }
    }
    cout << '\n';
  }
  return 0;
}
