#include <bits/stdc++.h>
using namespace std;
bool isSuff(string &a, string &b) {
  if (a.size() > b.size()) return false;
  for (int i = 1; i <= a.size(); i++) {
    if (a[a.size() - i] != b[b.size() - i]) return false;
  }
  return true;
}
string s;
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  map<string, vector<string> > q;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s >> m;
    for (int j = 0; j < m; j++) {
      string p;
      cin >> p;
      bool ok = true;
      for (auto k = q[s].begin(); k != q[s].end(); k++) {
        if (isSuff(p, *k)) {
          ok = false;
        }
      }
      if (!ok) continue;
      bool deleted;
      do {
        deleted = false;
        for (auto k = q[s].begin(); k != q[s].end(); k++) {
          if (isSuff(*k, p)) {
            q[s].erase(k);
            deleted = true;
            break;
          }
        }
      } while (deleted);
      q[s].push_back(p);
    }
  }
  cout << q.size() << endl;
  for (auto i = q.begin(); i != q.end(); i++) {
    cout << i->first << ' ' << i->second.size() << ' ';
    for (auto j : i->second) {
      cout << j << ' ';
    }
    cout << endl;
  }
  return 0;
}
