#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
template <typename T1, typename T2>
inline void chkmin(T1& x, T2 y) {
  if (y < x) x = y;
};
template <typename T1, typename T2>
inline void chkmax(T1& x, T2 y) {
  if (y > x) x = y;
};
int gcd(int x, int y) { return (y == 0 ? x : gcd(y, x % y)); }
const int MAXN = 3e5 + 100;
string suff[MAXN], pref[MAXN], second;
int n, m, t;
bool cmp(string& a, string& b) { return ((int)a.size() < (int)b.size()); }
bool check(string a, string b) {
  for (int i = (int)a.size() - 1, j = (int)b.size() - 1; i >= 0; i--, j--)
    if (a[i] != b[j]) return 0;
  return 1;
}
void solve() {
  map<string, vector<string>> hash;
  cin >> t;
  for (int i = 1; i < t + 1; i++) {
    cin >> second >> n;
    for (int i = 0; i < n; i++) {
      cin >> pref[i];
      hash[second].push_back(pref[i]);
    }
  }
  cout << (int)hash.size() << endl;
  for (auto it : hash) {
    cout << it.first << " ";
    n = 0;
    for (int i = 0; i < (int)hash[it.first].size(); i++)
      pref[n++] = hash[it.first][i];
    sort(pref, pref + n, cmp);
    m = 0;
    for (int i = 0; i < n; i++) {
      bool first = 1;
      for (int j = i + 1; j < n; j++) {
        if (check(pref[i], pref[j])) {
          first = 0;
          break;
        }
      }
      if (first) suff[m++] = pref[i];
    }
    cout << m;
    for (int i = 0; i < m; i++) cout << " " << suff[i] << endl;
  }
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
