#include <bits/stdc++.h>
using namespace std;
int n;
struct entry {
  string name;
  int num;
  string phone[300];
};
bool judge(string phone, string p[], int index, int len) {
  string::size_type idx;
  string::size_type idx2;
  int l = 0;
  for (int i = 0; i < len; i++) {
    if (index != i) {
      reverse(p[i].begin(), p[i].end());
      reverse(phone.begin(), phone.end());
      idx = p[i].find(phone);
      if (idx == string::npos || idx != 0) {
        reverse(p[i].begin(), p[i].end());
        reverse(phone.begin(), phone.end());
        continue;
      } else if (idx == 0) {
        reverse(p[i].begin(), p[i].end());
        reverse(phone.begin(), phone.end());
        return false;
      }
    }
  }
  return true;
}
bool judge2(string phone, string p[], int len) {
  string::size_type idx;
  for (int i = 0; i < len; i++) {
    idx = p[i].find(phone);
    if (idx == string::npos) {
      continue;
    } else if ((idx + phone.length()) == p[i].length()) {
      return false;
    }
  }
  return true;
}
void each(entry &e) {
  for (int i = 0; i < e.num; i++) {
    if (!judge(e.phone[i], e.phone, i, e.num)) {
      e.phone[i] = "-1-";
    }
  }
  for (int i = 0; i < e.num;) {
    if (e.phone[i] == "-1-") {
      for (int j = i; j < e.num; j++) {
        if (j == (e.num - 1)) {
          e.phone[j] = "";
        } else {
          e.phone[j] = e.phone[j + 1];
        }
      }
      e.num--;
    } else {
      i++;
    }
  }
}
int main() {
  scanf("%d", &n);
  entry e[25];
  for (int i = 0; i < n; i++) {
    cin >> e[i].name >> e[i].num;
    for (int j = 0; j < e[i].num; j++) {
      cin >> e[i].phone[j];
    }
  }
  for (int i = 0; i < n; i++) {
    each(e[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (e[i].name == e[j].name) {
        for (int k = 0; k < e[j].num; k++) {
          if (!judge2(e[j].phone[k], e[i].phone, e[i].num)) {
            e[j].phone[k] = "-1";
          } else {
            int t = 0;
            while (e[i].phone[t] != "") {
              t++;
            }
            e[i].phone[t] = e[j].phone[k];
            e[i].num++;
          }
        }
        e[j].num = 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    each(e[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (e[i].num != 0) {
      ans++;
    }
  }
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    if (e[i].num != 0) {
      cout << e[i].name << " " << e[i].num;
      for (int j = 0; j < e[i].num; j++) {
        cout << " " << e[i].phone[j];
      }
      cout << endl;
    }
  }
  return 0;
}
