#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
const long long int N = 1e5 + 10;
long long int mod = 1e9 + 7;
long long int dx[4] = {0, 0, +1, -1};
long long int dy[4] = {+1, -1, 0, 0};
long long int po(long long int a, long long int b) {
  a %= mod;
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
bool cmp(const string &a, const string &b) {
  if ((long long int)a.size() == (long long int)b.size())
    return a < b;
  else
    return (long long int)a.size() < (long long int)b.size();
}
long long int cal(string a, string b) {
  long long int la = (long long int)a.size();
  long long int lower_bound = (long long int)b.size();
  long long int i = la - 1, j = lower_bound - 1;
  while (i >= 0 && j >= 0) {
    if (a[i] == b[j]) {
      i--;
      j--;
    } else {
      return 0;
    }
  }
  return 1;
}
void solve() {
  long long int n;
  cin >> n;
  map<string, vector<string> > mp, ans;
  for (long long int i = 0; i < n; i++) {
    string s;
    cin >> s;
    long long int k;
    cin >> k;
    for (long long int j = 0; j < k; j++) {
      string x;
      cin >> x;
      mp[s].push_back(x);
    }
  }
  for (auto to : mp) {
    vector<string> ns;
    for (auto it : to.second) ns.push_back(it);
    sort((ns).begin(), (ns).end(), cmp);
    for (long long int i = 0; i < (long long int)ns.size(); i++) {
      long long int f = 0;
      for (long long int j = i + 1; j < (long long int)ns.size(); j++) {
        if (cal(ns[i], ns[j])) {
          f = 1;
          break;
        }
      }
      if (!f) {
        ans[to.first].push_back(ns[i]);
      }
    }
  }
  cout << (long long int)ans.size() << "\n";
  for (auto to : ans) {
    cout << to.first << " ";
    cout << (long long int)to.second.size() << " ";
    for (long long int i = 0; i < (long long int)to.second.size(); i++)
      cout << to.second[i] << " ";
    cout << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) solve();
  return 0;
}
