#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7, maxd = 1e8;
const long long mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
int T, n;
map<string, vector<string> > mp;
set<string> name;
bool is_ok(string a, string b) {
  if (a.length() < b.length()) return false;
  int aa = a.length() - 1, bb = b.length() - 1;
  while (bb >= 0) {
    if (a[aa] != b[bb]) return false;
    aa--;
    bb--;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  ;
  cin >> n;
  string s, t;
  int m;
  for (int i = 0; i < n; ++i) {
    cin >> s >> m;
    name.insert(s);
    for (int j = 0; j < m; ++j) {
      cin >> t;
      mp[s].push_back(t);
    }
  }
  set<string>::iterator it;
  int vis[21][1111], cnt = 0;
  memset(vis, 0, sizeof vis);
  for (it = name.begin(); it != name.end(); ++it) {
    for (int i = 0; i < mp[*it].size(); ++i) {
      for (int j = i + 1; j < mp[*it].size(); ++j) {
        if (vis[cnt][i] || vis[cnt][j]) continue;
        if (is_ok(mp[*it][i], mp[*it][j])) {
          vis[cnt][j] = 1;
        } else if (is_ok(mp[*it][j], mp[*it][i])) {
          vis[cnt][i] = 1;
        }
      }
    }
    cnt++;
  }
  cout << name.size() << endl;
  int pos = 0;
  for (it = name.begin(); it != name.end(); ++it) {
    cout << (*it) << " ";
    int num = 0;
    for (int i = 0; i < mp[*it].size(); ++i) {
      if (vis[pos][i] == 0) num++;
    }
    cout << num;
    for (int i = 0; i < mp[*it].size(); ++i) {
      if (!vis[pos][i]) {
        cout << " " << mp[*it][i];
      }
    }
    cout << endl;
    pos++;
  }
  return 0;
}
