#include <bits/stdc++.h>
using namespace std;
map<string, set<string> > Rec;
bool is_prefix(string a, string b) {
  bool flag = true;
  int al = a.length(), bl = b.length();
  if (al <= bl) {
    for (int i = 0; i < al; i++)
      if (a[al - i - 1] != b[bl - i - 1]) flag = false;
  } else
    return false;
  return flag;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string name;
    cin >> name;
    int _n;
    cin >> _n;
    for (int j = 0; j < _n; j++) {
      string num;
      cin >> num;
      bool should = true;
      vector<string> V;
      V.clear();
      for (set<string>::iterator it = Rec[name].begin(); it != Rec[name].end();
           it++) {
        if (is_prefix(*it, num)) {
          V.push_back(*it);
        } else if (is_prefix(num, *it)) {
          should = false;
        }
      }
      for (int it = 0; it < V.size(); it++) Rec[name].erase(V[it]);
      if (should) Rec[name].insert(num);
    }
  }
  cout << Rec.size() << endl;
  for (map<string, set<string> >::iterator it = Rec.begin(); it != Rec.end();
       it++) {
    cout << it->first << ' ' << it->second.size() << ' ';
    for (set<string>::iterator itt = it->second.begin();
         itt != it->second.end(); itt++) {
      cout << *itt << ' ';
    }
    cout << endl;
  }
}
