#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, INF = 1e9 + 7;
map<string, vector<string> > Map;
bool cmp(string a, string b) { return a.size() > b.size(); }
set<string> Set;
bool f(string a, string b) {
  for (int i = a.size() - 1, j = b.size() - 1; i >= 0 and j >= 0; i--, j--) {
    if (a[i] != b[j]) return 0;
  }
  return 1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string name;
    int k;
    cin >> name >> k;
    Set.insert(name);
    while (k--) {
      string s;
      cin >> s;
      Map[name].push_back(s);
    }
  }
  cout << Set.size() << endl;
  for (auto it = Map.begin(); it != Map.end(); it++) {
    cout << (it->first);
    vector<string> v = it->second;
    sort(v.begin(), v.end(), cmp);
    vector<string> ans;
    for (int i = v.size() - 1; i >= 0; i--) {
      int flag = 1;
      for (int j = i - 1; j >= 0; j--) {
        if (f(v[i], v[j])) {
          flag = 0;
          break;
        }
      }
      if (flag) ans.push_back(v[i]);
    }
    cout << " " << (int)ans.size();
    for (auto s : ans) {
      cout << " " << s;
    }
    cout << endl;
  }
}
