#include <bits/stdc++.h>
using namespace std;
int n, tot;
map<string, int> Id;
set<string> St[25];
bool mark[2005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string name;
    cin >> name;
    if (Id.find(name) == Id.end()) Id[name] = ++tot;
    int m;
    cin >> m;
    int id = Id[name];
    for (int i = 1; i <= m; i++) {
      string num;
      cin >> num;
      St[id].insert(num);
    }
  }
  printf("%d\n", tot);
  for (map<string, int>::iterator it = Id.begin(); it != Id.end(); it++) {
    cout << (it->first) << ' ';
    int id = it->second;
    vector<string> tmp;
    tmp.clear();
    for (set<string>::iterator its = St[id].begin(); its != St[id].end(); its++)
      tmp.push_back(*its);
    memset(mark, 0, sizeof(mark));
    for (int i = 0; i < (int)tmp.size(); i++)
      for (int j = 0; j < (int)tmp.size(); j++) {
        if (i == j || tmp[i].length() > tmp[j].length()) continue;
        bool f = true;
        for (int k = 0; k < tmp[i].length(); k++)
          if (tmp[j][tmp[j].length() - k - 1] !=
              tmp[i][tmp[i].length() - k - 1])
            f = false;
        if (f) mark[i] = true;
      }
    int cnt = 0;
    for (int i = 0; i < (int)tmp.size(); i++) cnt += (!mark[i]);
    printf("%d ", cnt);
    for (int i = 0; i < (int)tmp.size(); i++)
      if (!mark[i]) cout << tmp[i] << ' ';
    cout << endl;
  }
  return 0;
}
