#include <bits/stdc++.h>
using namespace std;
bool check(string a, string b) {
  long long n1 = a.length(), n2 = b.length();
  if (n1 > n2) return 0;
  long long ptr = n2 - 1;
  for (long long i = n1 - 1; i >= 0; i--) {
    if (a[i] != b[ptr]) return false;
    ptr--;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  map<string, long long> mp;
  map<long long, string> raj;
  long long k = 0;
  set<string> s[21];
  set<string> dstrings;
  set<string>::iterator it, it1;
  for (long long i = 0; i < n; i++) {
    string name;
    cin >> name;
    if (mp.find(name) == mp.end()) {
      mp[name] = k;
      raj[k] = name;
      k++;
    }
    long long p;
    cin >> p;
    string phone;
    for (long long j = 0; j < p; j++) {
      cin >> phone;
      s[mp[name]].insert(phone);
    }
    dstrings.insert(name);
  }
  cout << dstrings.size() << endl;
  for (long long i = 0; i < dstrings.size(); i++) {
    cout << raj[i] << " ";
    vector<string> ans;
    vector<string> temp;
    for (it = s[i].begin(); it != s[i].end(); it++) temp.push_back(*it);
    for (long long j = 0; j < temp.size(); j++) {
      bool flag = 1;
      for (long long k = 0; k < temp.size(); k++) {
        if (k == j) continue;
        if (check(temp[j], temp[k])) {
          flag = 0;
          break;
        }
      }
      if (flag) ans.push_back(temp[j]);
    }
    cout << ans.size() << " ";
    for (long long j = 0; j < ans.size(); j++) cout << ans[j] << " ";
    cout << endl;
  }
}
