#include <bits/stdc++.h>
using namespace std;
const int inv = 1000000000;
const int minv = -inv;
int n, k;
string name, number;
map<string, vector<string> > M;
map<string, vector<string> >::iterator it;
int main() {
  M.clear();
  scanf("%d", &n);
  for (int z = 0; z < n; ++z) {
    cin >> name;
    if (M.find(name) == M.end()) M[name] = vector<string>(0);
    scanf("%d", &k);
    for (int y = 0; y < k; ++y) {
      cin >> number;
      vector<string>& numbers = M[name];
      bool repeat = false;
      for (int i = 0; i < (int)numbers.size(); ++i)
        if (numbers[i] == number) {
          repeat = true;
          break;
        }
      if (not repeat) numbers.push_back(number);
    }
  }
  printf("%d\n", (int)M.size());
  for (it = M.begin(); it != M.end(); ++it) {
    name = it->first;
    vector<string>& numbers = it->second;
    cout << name << " ";
    int ct = 0;
    for (int i = 0; i < (int)numbers.size(); ++i) {
      number = numbers[i];
      bool repeat = false;
      for (int i = 0; i < (int)numbers.size(); ++i)
        if (numbers[i].length() > number.length() and
            numbers[i].substr(numbers[i].length() - number.length()) ==
                number) {
          repeat = true;
          break;
        }
      ct += (not repeat);
    }
    printf("%d ", ct);
    for (int i = 0; i < (int)numbers.size(); ++i) {
      number = numbers[i];
      bool repeat = false;
      for (int i = 0; i < (int)numbers.size(); ++i)
        if (numbers[i].length() > number.length() and
            numbers[i].substr(numbers[i].length() - number.length()) ==
                number) {
          repeat = true;
          break;
        }
      if (not repeat) cout << numbers[i] << " ";
    }
    printf("\n");
  }
  return 0;
}
