#include <bits/stdc++.h>
using namespace std;
int n, k;
string s, x;
map<string, set<string>> m;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s >> k;
    for (int j = 1; j <= k; j++) {
      cin >> x;
      m[s].insert(x);
    }
  }
  cout << m.size() << endl;
  for (auto u : m) {
    set<string> cleaned;
    for (string t : u.second) {
      bool bad = false;
      for (string tt : u.second) {
        if (t.size() < tt.size()) {
          if (t == tt.substr(tt.size() - t.size(), t.size())) {
            bad = true;
          }
        }
      }
      if (!bad) {
        cleaned.insert(t);
      }
    }
    cout << u.first << " " << cleaned.size() << " ";
    for (string t : cleaned) {
      cout << t << " ";
    }
    cout << endl;
  }
  return 0;
}
