#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> mp;
int idx, cnt;
vector<string> q[30];
string name[30];
bool stt[30], st[30][211];
int get(string x) {
  if (mp[x] == 0) mp[x] = ++idx;
  return mp[x];
}
bool check(string s1, string s2) {
  if (s1.size() > s2.size()) swap(s1, s2);
  int len1 = s1.size(), len2 = s2.size();
  bool flag = true;
  for (int i = len2 - len1; i <= len2 - 1; i++) {
    if (s1[i - len2 + len1] != s2[i]) flag = false;
  }
  return flag;
}
int main() {
  int n, m;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> name[i];
    int pos = get(name[i]);
    cin >> m;
    for (int i = 1; i <= m; i++) {
      cin >> s;
      q[pos].push_back(s);
      st[pos][q[pos].size() - 1] = true;
    }
  }
  cout << idx << endl;
  for (int c = 1; c <= n; c++) {
    int x = get(name[c]);
    if (!stt[x]) {
      stt[x] = true;
      cnt = q[x].size();
      for (int i = 0; i < q[x].size(); i++)
        for (int j = 0; j < q[x].size(); j++) {
          if (i == j) continue;
          if (st[x][i] && st[x][j])
            if (check(q[x][i], q[x][j])) {
              if (q[x][i].size() < q[x][j].size())
                st[x][i] = false;
              else
                st[x][j] = false;
              cnt--;
            }
        }
      cout << name[c] << " ";
      cout << cnt << " ";
      for (int i = 0; i < q[x].size(); i++)
        if (st[x][i]) cout << q[x][i] << " ";
      cout << endl;
    }
  }
}
