#include <bits/stdc++.h>
using namespace std;
string names[20];
vector<string> x[20], step2[20];
vector<string> z;
map<string, bool> q;
bool ch(string a, string b) { return a.size() > b.size(); }
void solve(int x) {
  sort(step2[x].begin(), step2[x].end(), ch);
  vector<string> ans;
  set<string> z;
  for (int i = 0; i < step2[x].size(); i++) z.insert(step2[x][i]);
  for (set<string>::iterator it = z.begin(); it != z.end(); it++) {
    string a = *it, b;
    int x = a.size(), y = 0;
    bool g = false;
    for (set<string>::iterator it2 = z.begin(); it2 != z.end(); it2++) {
      b = *it2;
      y = b.size();
      if (y > x && b.substr(y - x, y) == a) {
        g = true;
        break;
      }
    }
    if (!g) ans.push_back(*it);
  }
  cout << ans.size() << " ";
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
}
int main() {
  int n, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    string b;
    cin >> names[i] >> a;
    for (int i2 = 0; i2 < a; i2++) {
      cin >> b, x[i].push_back(b);
    }
    if (!q[names[i]]) {
      z.push_back(names[i]), q[names[i]] = true;
    }
  }
  for (int i = 0; i < n; i++) {
    if (names[i] == "0") continue;
    for (int i2 = i; i2 < n; i2++) {
      if (names[i] == names[i2]) {
        for (int i3 = 0; i3 < x[i2].size(); i3++)
          step2[cnt].push_back(x[i2][i3]);
        if (i2 != i) names[i2] = "0";
      }
    }
    cnt++;
  }
  cout << z.size() << endl;
  for (int i = z.size() - 1; i >= 0; i--) {
    cout << z[i] << " ", solve(i);
  }
  return 0;
}
