#include <bits/stdc++.h>
using namespace std;
bool cmp(string x, string y) { return x.size() > y.size(); }
bool is_suffix(string x, string y) {
  reverse(x.begin(), x.end());
  reverse(y.begin(), y.end());
  int j = 0;
  while (j < y.size()) {
    if (x[j] != y[j]) {
      return 0;
    }
    j++;
  }
  return 1;
}
void solve() {
  long long n;
  cin >> n;
  map<string, vector<string> > m1;
  string temp;
  int cnt;
  string a;
  set<string> zz;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    zz.insert(temp);
    cin >> cnt;
    while (cnt--) {
      cin >> a;
      m1[temp].push_back(a);
    }
  }
  cout << zz.size() << "\n";
  set<string>::iterator itr;
  itr = zz.begin();
  while (itr != zz.end()) {
    temp = (*itr);
    sort(m1[*itr].begin(), m1[*itr].end(), cmp);
    vector<string> ans;
    for (int i = 0; i < m1[*itr].size(); i++) {
      if (m1[temp][i] == "") {
        continue;
      }
      ans.push_back(m1[temp][i]);
      for (int j = i + 1; j < m1[temp].size(); j++) {
        if (m1[temp][j] == "") {
          continue;
        }
        if (is_suffix(m1[temp][i], m1[temp][j])) {
          m1[temp][j] = "";
        }
      }
    }
    cout << temp << " " << ans.size() << " ";
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
    cout << "\n";
    itr++;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long t = 1;
  while (t--) {
    solve();
  }
}
