#include <bits/stdc++.h>
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 0.00000000000000000000001;
using namespace std;
map<string, vector<string> > v;
map<string, long long> us, us2;
vector<string> a;
map<string, vector<pair<long long, string> > > post;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, i, j, k;
  cin >> n;
  for (i = 1; i <= n; i++) {
    string s;
    cin >> s >> k;
    if (us2[s] == 0) {
      us2[s] = 1;
      a.push_back(s);
    }
    for (j = 1; j <= k; j++) {
      string s1;
      cin >> s1;
      post[s].push_back({s1.size(), s1});
    }
    sort(post[s].begin(), post[s].end());
    reverse(post[s].begin(), post[s].end());
  }
  for (i = 0; i < a.size(); i++) {
    string s = a[i];
    for (j = 0; j < post[s].size(); j++) {
      string s1 = post[s][j].second;
      if (us[s1] == 0) v[s].push_back(s1);
      string x = "";
      for (long long w = s1.size() - 1; w >= 0; w--) {
        x = s1[w] + x;
        us[x] = 1;
      }
    }
    us.clear();
    post[s].clear();
  }
  cout << a.size() << '\n';
  for (i = 0; i < a.size(); i++) {
    cout << a[i] << " ";
    cout << v[a[i]].size() << " ";
    for (j = 0; j < v[a[i]].size(); j++) {
      cout << v[a[i]][j] << " ";
    }
    cout << '\n';
  }
  return 0;
}
