#include <bits/stdc++.h>
using namespace std;
bool is_suffix(string a, string b) {
  if (b.size() < a.size()) return 0;
  for (int i = a.size() - 1; i >= 0; i--) {
    if (a[i] != b[i]) return 0;
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(0);
  map<string, set<string> > list;
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    string name;
    int n;
    cin >> name >> n;
    for (int i = 0; i < n; i++) {
      string x;
      cin >> x;
      list[name].insert(x);
    }
  }
  cout << list.size() << '\n';
  for (auto it : list) {
    vector<string> nums;
    map<string, bool> no;
    for (string a : it.second) {
      bool ok = 0;
      for (string b : it.second) {
        if (a == b) continue;
        if (a.size() < b.size()) {
          string ta = b.substr(b.size() - a.size(), a.size());
          if (ta == a) ok = 1;
        }
      }
      if (!ok) nums.push_back(a);
    }
    cout << it.first << " " << nums.size() << " ";
    for (int r = 0; r < nums.size(); r++) cout << nums[r] << " ";
    cout << '\n';
    nums.clear();
    no.clear();
  }
}
