#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 30;
map<string, long long> mp;
set<string> name;
set<string> st[MAXN];
bool suffix(string &s, string &t) {
  if (t.size() > s.size()) return false;
  long long tln = t.size(), sln = s.size();
  for (long long i = sln - tln, j = 0; i < sln; j++, i++)
    if (s[i] != t[j]) return false;
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    string s, num;
    long long t, ind;
    cin >> s >> t;
    if (name.find(s) == name.end()) {
      name.insert(s);
      mp[s] = name.size();
    }
    ind = mp[s];
    while (t--) {
      cin >> num;
      st[ind].insert(num);
    }
  }
  for (auto x : mp) {
    set<string> mrk;
    for (auto s : st[x.second]) {
      if (mrk.find(s) != mrk.end()) continue;
      for (auto t : st[x.second]) {
        if (s == t || mrk.find(t) != mrk.end()) continue;
        if (suffix(s, t)) mrk.insert(t);
      }
    }
    for (auto s : mrk) st[x.second].erase(s);
  }
  cout << mp.size() << endl;
  for (auto x : mp) {
    cout << x.first << " " << st[x.second].size() << " ";
    for (auto s : st[x.second]) cout << s << " ";
    cout << endl;
  }
}
