#include <bits/stdc++.h>
using namespace std;
struct Friend {
  string name;
  vector<string> phones;
};
bool suffix(const string &x, const string &y) {
  if (x.length() > y.length()) return false;
  for (int i = 0, j = y.length() - x.length(); i < x.length(); ++i, ++j)
    if (x[i] != y[j]) return false;
  return true;
}
int n, t, k;
vector<Friend> x;
vector<Friend> y;
string name, phone;
int find_name(const vector<Friend> &x, const string &name) {
  for (int i = 0; i < x.size(); ++i)
    if (x[i].name == name) return i;
  return -1;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> name;
    t = find_name(x, name);
    if (t == -1) {
      x.push_back(Friend());
      x.back().name = name;
      cin >> k;
      for (int j = 0; j < k; ++j) {
        cin >> phone;
        x.back().phones.push_back(phone);
      }
    } else {
      x[t].name = name;
      cin >> k;
      for (int j = 0; j < k; ++j) {
        cin >> phone;
        x[t].phones.push_back(phone);
      }
    }
  }
  for (int i = 0; i < x.size(); ++i) {
    for (int j = 0; j < x[i].phones.size(); ++j) {
      for (int k = 0; k < x[i].phones.size(); ++k) {
        if (suffix(x[i].phones[j], x[i].phones[k])) {
          x[i].phones[j] = x[i].phones[k];
        }
      }
    }
    for (int j = 0; j < x[i].phones.size(); ++j) {
      for (int k = j + 1; k < x[i].phones.size(); ++k) {
        if (x[i].phones[j] == x[i].phones[k]) {
          x[i].phones[k].clear();
        }
      }
    }
    auto s = x[i].phones;
    x[i].phones.clear();
    for (int j = 0; j < s.size(); ++j) {
      if (!s[j].empty()) {
        x[i].phones.push_back(s[j]);
      }
    }
  }
  cout << x.size() << endl;
  for (int i = 0; i < x.size(); ++i) {
    cout << x[i].name << ' ' << x[i].phones.size() << ' ';
    for (int j = 0; j < x[i].phones.size(); ++j) {
      cout << x[i].phones[j] << ' ';
    }
    cout << endl;
  }
}
