#include <bits/stdc++.h>
using namespace std;
const long long N = 2e3 + 4, MAX = 4e5 + 1, INF = 2e18, mod = 1e9 + 7;
long double PI = 3.14159265359;
long long n, t, cnt;
string a, b;
vector<string> v[N];
map<string, long long> m;
set<string> s[25];
map<long long, string> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    t += (m[a] == 0);
    if (!m[a]) m[a] = t, mp[t] = a;
    long long k;
    cin >> k;
    for (int i = 1; i <= k; i++) {
      cin >> b;
      s[m[a]].insert(b);
    }
  }
  cout << t << '\n';
  for (int i = 1; i <= t; i++)
    for (auto u : s[i]) v[i].push_back(u);
  for (int i = 1; i <= t; i++) {
    cnt = 0;
    map<string, bool> d;
    for (int j = 0; j < v[i].size(); j++) {
      for (int h = j + 1; h < v[i].size(); h++) {
        a = v[i][j];
        b = v[i][h];
        reverse(a.begin(), a.end());
        reverse(b.begin(), b.end());
        if (a.size() < b.size()) swap(a, b);
        a.resize(b.size());
        if (a == b) {
          reverse(a.begin(), a.end());
          d[a] = 1;
        }
      }
    }
    for (int j = 0; j < v[i].size(); j++) cnt += (d[v[i][j]] == 0);
    cout << mp[i] << ' ' << cnt << ' ';
    for (int j = 0; j < v[i].size(); j++)
      if (!d[v[i][j]]) cout << v[i][j] << ' ';
    cout << endl;
  }
}
