#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool ends_with(string a, string b) {
  int g = a.size(), l = b.size();
  if (g < l) return 0;
  for (int i = 0; i < l; i++) {
    if (b[l - 1 - i] != a[g - 1 - i]) return 0;
  }
  return 1;
}
int main() {
  int n, num, val = 0;
  cin >> n;
  map<string, int> mp1;
  map<int, string> mp2;
  vector<string> v[30];
  for (int i = 0; i < n; i++) {
    string name, x;
    cin >> name >> num;
    if (mp1.find(name) == mp1.end()) {
      mp1[name] = val++;
      mp2[val - 1] = name;
    }
    for (int j = 0; j < num; j++) {
      cin >> x;
      int now = mp1[name];
      bool ok = false;
      for (int k = 0; k < v[now].size(); k++) {
        if (ends_with(v[now][k], x)) {
          ok = true;
          break;
        }
      }
      if (!ok) v[now].push_back(x);
      for (int k = 0; k < v[now].size(); k++) {
        if (ends_with(x, v[now][k]) && v[now][k] != x) {
          v[now].erase(v[now].begin() + k);
          break;
        }
      }
    }
  }
  cout << val << '\n';
  for (int i = 0; i < val; i++) {
    cout << mp2[i] << ' ' << v[i].size() << ' ';
    for (int j = 0; j < v[i].size(); j++) cout << v[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}
