#include <bits/stdc++.h>
using namespace std;
struct node {
  string phone;
  int len;
  bool operator<(const node &a) const { return a.len > len; }
};
int n;
char name[20];
int m;
bool ifhz(string s1, string s2) {
  int len1 = s1.size() - 1, len2 = s2.size() - 1;
  while (len1 >= 0 && len2 >= 0) {
    if (s1[len1] != s2[len2]) {
      return false;
    }
    len1--;
    len2--;
  }
  if (s2.size() > s1.size()) {
    return true;
  }
  return false;
}
int main() {
  while (~scanf("%d", &n)) {
    map<string, set<string> > mp;
    set<string> st[20];
    for (int k = 0; k < n; k++) {
      scanf("%s", name);
      scanf("%d", &m);
      char s[20];
      for (int i = 0; i < m; i++) {
        scanf("%s", s);
        mp[name].insert(s);
      }
    }
    int cnt = -1;
    map<string, set<string> >::iterator it;
    for (it = mp.begin(); it != mp.end(); it++) {
      cnt++;
      set<string>::iterator iot, iotr;
      for (iot = it->second.begin(); iot != it->second.end(); iot++) {
        int flag = 1;
        for (iotr = it->second.begin(); iotr != it->second.end(); iotr++) {
          if (iotr == iot) continue;
          if (ifhz((*iot), (*iotr))) {
            flag = 0;
            break;
          }
        }
        if (flag) st[cnt].insert((*iot));
      }
    }
    printf("%d\n", mp.size());
    int i = -1;
    for (it = mp.begin(); it != mp.end(); it++) {
      i++;
      cout << it->first << " ";
      printf("%d", st[i].size());
      set<string>::iterator iot;
      for (iot = st[i].begin(); iot != st[i].end(); iot++) {
        cout << " " << *iot;
      }
      printf("\n");
    }
  }
  return 0;
}
