#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
int inf = 2e9;
template <typename T>
void print(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) cout << a[i] << ' ';
}
template <typename T>
void input(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) cin >> a[i];
}
bool cmp(string& a, string& b) { return a.length() > b.length(); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  map<string, int> ma;
  vector<string> names;
  vector<vector<string>> arr;
  int num = 0;
  for (int i = 0; i < n; i++) {
    string name;
    cin >> name;
    int pos;
    if (ma[name] == 0) {
      num++;
      ma[name] = num;
      arr.push_back(vector<string>());
      names.push_back(name);
    }
    pos = ma[name] - 1;
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      string number;
      cin >> number;
      arr[pos].push_back(number);
    }
  }
  vector<vector<string>> ans(arr.size());
  for (int i = 0; i < arr.size(); i++) {
    sort(arr[i].begin(), arr[i].end(), cmp);
  }
  cout << num << '\n';
  for (int i = 0; i < arr.size(); i++) {
    for (int j = 0; j < arr[i].size(); j++) {
      string str = arr[i][j];
      string str1 = str;
      reverse(str.begin(), str.end());
      bool flag = true;
      for (int k = 0; k < ans[i].size(); k++) {
        string to = ans[i][k];
        reverse((to).begin(), (to).end());
        bool flag2 = true;
        for (int c = 0; c < str.length(); c++) {
          if (str[c] != to[c]) {
            flag2 = false;
          }
        }
        if (flag2 == true) {
          flag = false;
        }
        if (!flag) break;
      }
      if (flag) ans[i].push_back(str1);
    }
    cout << names[i] << " " << ans[i].size() << " ";
    for (int j = 0; j < ans[i].size(); j++) {
      cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }
}
