#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 10000;
map<string, vector<string>> mp;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string name;
    int num;
    cin >> name;
    cin >> num;
    vector<string> temp = mp[name];
    for (int j = 0; j < num; j++) {
      string s;
      cin >> s;
      temp.push_back(s);
    }
    sort(temp.begin(), temp.end());
    temp.resize(unique(temp.begin(), temp.end()) - temp.begin());
    mp[name] = temp;
  }
  for (map<string, vector<string>>::iterator it = mp.begin(); it != mp.end();
       it++) {
    vector<string> temp = mp[it->first];
    for (int i = 0; i < (int)temp.size(); i++) {
      for (int j = 0; j < (int)temp.size(); j++) {
        if (i != j) {
          if ((int)temp[i].size() < (int)temp[j].size() &&
              temp[i] ==
                  temp[j].substr((int)temp[j].size() - (int)temp[i].size(),
                                 (int)temp[j].size())) {
            temp[i] = "n";
          }
        }
      }
    }
    vector<string> res;
    for (int i = 0; i < (int)temp.size(); i++) {
      if (temp[i][0] != 'n') {
        res.push_back(temp[i]);
      }
    }
    mp[it->first] = res;
  }
  cout << (int)mp.size() << endl;
  for (map<string, vector<string>>::iterator it = mp.begin(); it != mp.end();
       it++) {
    int num = (int)mp[it->first].size();
    cout << it->first << " " << num;
    vector<string> s = mp[it->first];
    for (int i = 0; i < num; i++) {
      cout << " " << s[i];
    }
    cout << endl;
  }
  return 0;
}
