#include <bits/stdc++.h>
const double EPS = 1e-9;
using namespace std;
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
inline int nxt() {
  int wow;
  scanf("%d", &wow);
  return wow;
}
inline long long int lxt() {
  long long int wow;
  scanf("%lld", &wow);
  return wow;
}
inline double dxt() {
  double wow;
  scanf("%lf", &wow);
  return wow;
}
bool comp(string xx, string yy) {
  if (xx.length() == yy.length())
    return xx < yy;
  else
    return xx.length() > yy.length();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  map<string, vector<string>> phone, book;
  set<string> st;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    st.insert(s);
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
      string num;
      cin >> num;
      phone[s].push_back(num);
    }
  }
  for (auto it = st.begin(); it != st.end(); ++it) {
    sort(phone[*it].begin(), phone[*it].end(), comp);
    for (int i = 0; i < phone[*it].size(); i++) {
      bool dup = false;
      for (int j = 0; j < book[*it].size(); j++) {
        bool match = true;
        for (int k = phone[*it][i].length() - 1, l = book[*it][j].length() - 1;
             k >= 0; k--, l--) {
          if (phone[*it][i][k] != book[*it][j][l]) match = false;
        }
        if (match == true) dup = true;
      }
      if (dup == false) book[*it].push_back(phone[*it][i]);
    }
  }
  cout << st.size() << endl;
  for (auto it = st.begin(); it != st.end(); ++it) {
    cout << *it << " " << book[*it].size();
    for (int i = 0; i < book[*it].size(); i++) cout << " " << book[*it][i];
    cout << endl;
  }
  return 0;
}
