#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, cnt, m;
string second, t;
vector<string> g[100];
map<string, int> id;
map<int, string> st;
bool check(string second, string t) {
  string cur;
  if ((int)second.size() > (int)t.size()) return 1;
  for (int i = (int)t.size() - (int)second.size(); i < (int)t.size(); ++i) {
    cur += t[i];
  }
  if (cur == second) return 0;
  return 1;
}
void make(int pos) {
  vector<string> v;
  map<string, bool> x;
  for (int i = 0; i < (int)g[pos].size(); ++i) {
    if (x.count(g[pos][i]) == 0) {
      v.push_back(g[pos][i]);
      x[g[pos][i]] = 1;
    }
  }
  g[pos] = v;
  v.clear();
  for (int i = 0; i < (int)g[pos].size(); ++i) {
    bool bad = 0;
    for (int j = 0; j < (int)g[pos].size(); ++j) {
      if (i == j) continue;
      if (!check(g[pos][i], g[pos][j])) {
        bad = 1;
      }
    }
    if (!bad) {
      v.push_back(g[pos][i]);
    }
  }
  g[pos] = v;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> second;
    if (id.count(second) == 0) {
      id[second] = cnt;
      st[cnt] = second;
      cnt++;
    }
    int v = id[second];
    cin >> m;
    for (int i = 0; i < m; ++i) {
      cin >> t;
      g[v].push_back(t);
    }
  }
  for (int i = 0; i < cnt; ++i) {
    make(i);
  }
  cout << cnt << endl;
  for (int i = 0; i < cnt; ++i) {
    cout << st[i] << " " << (int)g[i].size() << " ";
    for (int j = 0; j < (int)g[i].size(); ++j) {
      cout << g[i][j] << " ";
    }
    cout << "\n";
  }
}
