#include <bits/stdc++.h>
using namespace std;
string w;
map<string, bool> vis;
int n, x = 0;
map<string, int> mp;
map<string, bool> mapi[25];
map<string, bool> inserted[25];
vector<string> v[25];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int koyta;
  cin >> koyta;
  for (int z = 0; z < koyta; z++) {
    string s;
    cin >> s;
    if (vis[s] == false) {
      vis[s] = true;
      mp[s] = x++;
    }
    cin >> n;
    int identify = mp[s];
    for (int i = 0; i < n; i++) {
      cin >> w;
      int sz = w.size();
      string p = "";
      for (int j = sz - 1; j >= 1; j--) {
        p = w[j] + p;
        mapi[identify][p] = true;
        inserted[identify][p] = false;
      }
      p = w[0] + p;
      if (mapi[identify][p] == false) {
        mapi[identify][p] = true;
        v[identify].push_back(p);
        inserted[identify][p] = true;
      }
    }
  }
  cout << mp.size() << endl;
  for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    vector<string> kx;
    int which = it->second;
    int sz = v[which].size();
    for (int i = 0; i < sz; i++) {
      string st = v[which][i];
      if (inserted[which][st] == true) kx.push_back(st);
    }
    cout << (it->first) << " " << kx.size();
    sz = kx.size();
    for (int i = 0; i < sz; i++) cout << " " << kx[i];
    cout << endl;
  }
}
