#include <bits/stdc++.h>
using namespace std;
bool isSuffix(string a, string b) {
  int n = a.size();
  int m = b.size();
  if (n > m) return false;
  return a == b.substr(m - n);
}
vector<string> process(set<string> st) {
  vector<string> v;
  for (auto x : st) {
    v.push_back(x);
  }
  sort(v.begin(), v.end(),
       [&](string a, string b) { return a.size() < b.size(); });
  vector<string> ret;
  for (int i = 0; i < v.size(); i++) {
    bool flg = true;
    for (int j = i + 1; j < v.size(); j++) {
      if (isSuffix(v[i], v[j])) {
        flg = false;
        break;
      }
    }
    if (flg) ret.push_back(v[i]);
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(32);
  int n;
  cin >> n;
  map<string, set<string> > mp;
  for (int i = 0; i < n; i++) {
    string s;
    int k;
    cin >> s >> k;
    for (int j = 0; j < k; j++) {
      string t;
      cin >> t;
      mp[s].insert(t);
    }
  }
  cout << mp.size() << '\n';
  for (auto x : mp) {
    cout << x.first << " ";
    vector<string> v = process(x.second);
    cout << v.size();
    for (auto x : v) {
      cout << " " << x;
    }
    cout << '\n';
  }
  return 0;
}
