#include <bits/stdc++.h>
using namespace std;
const int N = (3e5), mod = (1e9) + 7;
string second[N], r[N];
int n, m;
int t;
string name;
map<string, vector<string> > ma;
bool cmp(string a, string b) { return (a.size() < b.size()); }
bool check(string a, string b) {
  for (int i = int(a.size()) - 1, j = int(b.size()) - 1; i >= 0; i--, j--) {
    if (a[i] != b[j]) return 0;
  }
  return 1;
}
int main() {
  cin >> t;
  for (int j = 1; j <= t; j++) {
    cin >> name >> n;
    for (int i = 0; i < n; i++) {
      cin >> second[i];
      ma[name].push_back(second[i]);
    }
  }
  cout << int(ma.size()) << endl;
  for (auto p : ma) {
    cout << p.first << " ";
    n = 0;
    for (int i = 0; i < ma[p.first].size(); i++) {
      second[n++] = ma[p.first][i];
    }
    sort(second, second + n, cmp);
    m = 0;
    for (int i = 0; i < n; i++) {
      bool ok = 1;
      for (int j = i + 1; j < n; j++) {
        if (check(second[i], second[j])) {
          ok = 0;
          break;
        }
      }
      if (ok) r[m++] = second[i];
    }
    cout << m;
    for (int i = 0; i < m; i++) {
      cout << " " << r[i];
    }
    cout << endl;
  }
  return 0;
}
