#include <bits/stdc++.h>
using namespace std;
vector<string> vec[32], name;
vector<bool> ok[32];
map<string, int> mp;
bool check(string a, string b) {
  if (a.size() > b.size()) return 0;
  long long ch = b.size() - a.size();
  for (int i = 0; i < a.size(); i++)
    if (a[i] != b[i + ch]) return 0;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n, k = 1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string nam;
    int q, nn;
    cin >> nam >> q;
    if (mp[nam] == 0) {
      mp[nam] = k;
      name.push_back(nam);
      k++;
    }
    nn = mp[nam];
    for (int j = 0; j < q; j++) {
      string pp;
      cin >> pp;
      vec[nn].push_back(pp);
      ok[nn].push_back(1);
    }
  }
  cout << k - 1 << "\n";
  for (int i = 1; i < k; i++) {
    for (int j = 0; j < vec[i].size(); j++) {
      for (int z = 0; z < vec[i].size(); z++) {
        if (j == z || !ok[i][z]) continue;
        if (check(vec[i][j], vec[i][z])) ok[i][j] = 0;
      }
    }
    long long cnt = 0;
    for (int j = 0; j < vec[i].size(); j++)
      if (ok[i][j]) cnt++;
    cout << name[i - 1] << " " << cnt;
    for (int j = 0; j < vec[i].size(); j++)
      if (ok[i][j]) cout << " " << vec[i][j];
    cout << endl;
  }
}
