#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
vector<string> v[25];
bool go(string s, string p) {
  if ((long long)s.size() > (long long)p.size())
    return false;
  else {
    for (long long i = (long long)s.size() - 1, j = (long long)p.size() - 1;
         i >= 0 && j >= 0; i--, j--) {
      if (s[i] != p[j]) return false;
    }
    return true;
  }
}
vector<string> get(long long x) {
  long long i, j, n, m;
  vector<string> y, t;
  n = v[x].size();
  sort(v[x].begin(), v[x].end());
  for (i = 0; i < n;) {
    t.push_back(v[x][i]);
    for (j = i + 1; j < n; j++) {
      if (v[x][j] != v[x][i]) break;
    }
    i = j;
  }
  n = t.size();
  for (i = 0; i < n; i++) {
    int f = 0;
    for (j = 0; j < n; j++) {
      if (j != i && go(t[i], t[j]) == true) {
        f = 1;
        break;
      }
    }
    if (f == 0) y.push_back(t[i]);
  }
  return y;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long i, j, n, m, l, r;
  cin >> n;
  string s, p;
  map<string, long long> mp;
  for (i = 0, l = 0; i < n; i++) {
    cin >> s >> m;
    if (mp[s] == 0) mp[s] = ++l;
    for (j = 0; j < m; j++) {
      cin >> p;
      v[mp[s]].push_back(p);
    }
  }
  cout << l << "\n";
  for (auto it = mp.begin(); it != mp.end(); it++) {
    cout << it->first << " ";
    vector<string> ans = get(it->second);
    cout << (long long)ans.size();
    for (string xx : ans) cout << " " << xx;
    cout << "\n";
  }
  return 0;
}
