#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 15;
const long long int inf = 1e18;
bool match(string a, string b) {
  long long int i = a.size() - 1, j = b.size() - 1;
  while (i >= 0 and j >= 0 and b[j] == a[i]) i--, j--;
  return i < 0;
}
void solve() {
  long long int n;
  cin >> n;
  map<string, vector<string>> mp;
  for (long long int i = 1; i <= n; i++) {
    string name;
    cin >> name;
    long long int m;
    cin >> m;
    for (long long int j = 1; j <= m; j++) {
      string s;
      cin >> s;
      mp[name].push_back(s);
    }
  }
  for (auto &x : mp) {
    vector<string> all = x.second;
    vector<string> keep;
    sort(all.begin(), all.end(),
         [](string a, string b) { return a.size() < b.size(); });
    for (long long int i = 0; i < all.size(); i++) {
      bool chk = true;
      for (long long int j = i + 1; j < all.size(); j++) {
        if (match(all[i], all[j])) {
          chk = false;
          break;
        }
      }
      if (chk) keep.push_back(all[i]);
    }
    x.second = keep;
  }
  cout << mp.size() << "\n";
  for (auto x : mp) {
    cout << x.first << " " << x.second.size() << " ";
    for (auto y : x.second) cout << y << " ";
    cout << "\n";
  }
}
void debug(long long int tt) {}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
