#include <bits/stdc++.h>
using namespace std;
map<string, vector<string>> mp;
int n;
bool suff(string &x, string &y) {
  if (x.length() > y.length()) return 0;
  int len = y.length();
  for (int i = 0; i < x.length(); ++i) {
    if (x[i] != y[len - x.length() + i]) return 0;
  }
  return 1;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    string name;
    cin >> name;
    int num;
    cin >> num;
    for (int j = 1; j <= num; ++j) {
      string x;
      cin >> x;
      mp[name].push_back(x);
    }
  }
  for (auto &it : mp) {
    vector<string> &vt = it.second;
    vector<string> tmp;
    for (int i = 0; i < vt.size(); ++i) {
      bool flag = 0;
      for (int j = 0; j < vt.size(); ++j) {
        if (i == j) continue;
        if (suff(vt[i], vt[j])) {
          if (i < j && vt[i] == vt[j]) continue;
          flag = 1;
          break;
        }
      }
      if (!flag) tmp.push_back(vt[i]);
    }
    vt = tmp;
  }
  cout << mp.size() << endl;
  for (auto &it : mp) {
    vector<string> &vt = it.second;
    cout << it.first << ' ';
    cout << vt.size();
    for (auto &x : vt) cout << ' ' << x;
    cout << endl;
  }
  return 0;
}
