#include <bits/stdc++.h>
using namespace std;
map<string, set<string> > m;
bool isIn(const string& s, const string& t) {
  if (s.length() >= t.length()) return false;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] != t[t.length() - s.length() + i]) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    string name;
    int num;
    cin >> name >> num;
    for (int i = 1; i <= num; ++i) {
      string t;
      cin >> t;
      m[name].insert(t);
    }
  }
  cout << m.size() << endl;
  for (auto i : m) {
    vector<string> ans;
    for (const string& j : i.second) {
      bool flag = true;
      for (const string& k : i.second) {
        if (j == k) continue;
        if (isIn(j, k)) {
          flag = false;
          break;
        }
      }
      if (flag) ans.push_back(j);
    }
    cout << i.first << ' ' << ans.size() << ' ';
    for (auto t : ans) {
      cout << t << ' ';
    }
    cout << endl;
  }
  return 0;
}
