#include <bits/stdc++.h>
using namespace std;
map<string, map<string, int> > m;
int main() {
  int n, x;
  string s, str;
  string ans = "";
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s >> x;
    for (int j = 1; j <= x; j++) {
      cin >> str;
      ans = "";
      if (m[s][str] == 1) continue;
      for (int z = str.size() - 1; z > 0; z--) {
        ans = str[z] + ans;
        m[s][ans] = 1;
      }
      m[s][str] = 2;
    }
  }
  cout << m.size() << endl;
  for (auto it = m.begin(); it != m.end(); it++) {
    cout << it->first << " ";
    int kol = 0;
    for (auto i = it->second.begin(); i != it->second.end(); i++) {
      if ((i->second) == 2) kol++;
    }
    cout << kol << " ";
    for (auto i = it->second.begin(); i != it->second.end(); i++) {
      if ((i->second) == 2) cout << i->first << " ";
    }
    cout << endl;
  }
  return 0;
}
