#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = 1e9;
void debug(int* a, int n) {
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  cout << '\n';
}
void debug(vector<int> b, int n) {
  for (int i = 0; i < n; i++) cout << b[i] << " ";
  cout << '\n';
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int main() {
  int n, j = 0, k, m, i, y, flag;
  cin >> n;
  map<string, int> me;
  std::map<string, int>::iterator it;
  vector<string> a[25];
  int b[500];
  for (i = 0; i < n; i++) {
    string s;
    cin >> s >> m;
    it = me.find(s);
    if (it == me.end()) {
      me[s] = j;
      b[j] = m;
      for (k = 0; k < m; k++) {
        cin >> s;
        a[j].push_back(s);
      }
      j++;
    } else {
      int temp = me[s];
      b[temp] += m;
      for (k = 0; k < m; k++) {
        string xx;
        cin >> xx;
        a[temp].push_back(xx);
      }
    }
  }
  cout << j << endl;
  for (it = me.begin(); it != me.end(); ++it) {
    std::cout << it->first << " ";
    int temp = it->second;
    int hell = b[temp];
    long long z[500] = {0};
    for (i = 0; i < hell; i++) {
      if (z[i] == 1) continue;
      for (j = 0; j < hell; j++) {
        long long l1 = a[temp][i].length() - 1;
        long long l2 = a[temp][j].length() - 1;
        if (i == j || z[j] == 1 || l1 > l2) continue;
        flag = 0;
        for (y = l1; y >= 0; y--) {
          if (a[temp][i][y] != a[temp][j][l2]) {
            flag = 1;
            break;
          }
          l2--;
        }
        if (flag == 0) {
          z[i] = 1;
          b[temp]--;
          break;
        }
      }
    }
    cout << b[temp] << " ";
    for (i = 0; i < hell; i++) {
      string s = a[temp][i];
      if (z[i] != 1) cout << s << " ";
    }
    cout << endl;
  }
  return 0;
}
