#include <bits/stdc++.h>
using namespace std;
struct node{
node* pos[26];
node(){
for(int j = 0; j < 26; j++)
pos[j] = NULL;
}
};
bool add(node* root, string& s, int pos, int n){
if(pos == n-1){
node* curr = root->pos[s[pos] - 'a'];
if(curr) return false;
root->pos[s[pos] - 'a'] = new node;
return true;
}
if(root->pos[s[pos] - 'a']) return add(root->pos[s[pos] - 'a'], s, pos+1, n);
else{
root->pos[s[pos] - 'a'] = new node;
return add(root->pos[s[pos] - 'a'], s, pos+1, n);
}
}
map<string, int> m;
string at[12];
string arr[11][201];
int counts[11] = {0};
vector<string> ans[11];
int cnt = 1;
bool cmp(string& s1, string& s2){
return s1.size() > s2.size();
}
void build(){
int n;
cin >> n;
while(n--){
string name;
cin >> name;
int pos = 0;
if(m[name]) pos = m[name];
else{ m[name] = cnt; pos = cnt; at[cnt] = name; cnt++; }
int num;
cin >> num;
while(num--){
string s;
cin >> s;
arr[pos][counts[pos]++] = s;
}
}
for(int j = 1; j < cnt; j++)
sort(arr[j], arr[j] + counts[j], cmp);
}
void solve(){
for(int j = 1; j < cnt; j++){
node* root = new node;
for(int k = 0; k < counts[j]; k++)
if(add(root, arr[j][k], 0, arr[j][k].length())) ans[j].push_back(arr[j][k]);
}
}
int main(){
build();
cout << "builder complete!\n";
solve();
cout << (cnt-1) << endl;
for(int j = 1; j < cnt; j++){
cout << at[j] << " ";
cout << ans[j].size() << " ";
for(int k = 0; k < ans[j].size(); k++)
cout << ans[j][k] << " ";
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IG5vZGV7CiAgICBub2RlKiBwb3NbMjZdOwoKICAgIG5vZGUoKXsKICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgMjY7IGorKykKICAgICAgICAgICAgcG9zW2pdID0gTlVMTDsKICAgIH0KfTsKCmJvb2wgYWRkKG5vZGUqIHJvb3QsIHN0cmluZyYgcywgaW50IHBvcywgaW50IG4pewogICAgaWYocG9zID09IG4tMSl7CiAgICAgICAgbm9kZSogY3VyciA9IHJvb3QtPnBvc1tzW3Bvc10gLSAnYSddOwogICAgICAgIGlmKGN1cnIpIHJldHVybiBmYWxzZTsKICAgICAgICByb290LT5wb3Nbc1twb3NdIC0gJ2EnXSA9IG5ldyBub2RlOwogICAgICAgIHJldHVybiB0cnVlOwogICAgfQogICAgaWYocm9vdC0+cG9zW3NbcG9zXSAtICdhJ10pIHJldHVybiBhZGQocm9vdC0+cG9zW3NbcG9zXSAtICdhJ10sIHMsIHBvcysxLCBuKTsKICAgIGVsc2V7CiAgICAgICAgcm9vdC0+cG9zW3NbcG9zXSAtICdhJ10gPSBuZXcgbm9kZTsKICAgICAgICByZXR1cm4gYWRkKHJvb3QtPnBvc1tzW3Bvc10gLSAnYSddLCBzLCBwb3MrMSwgbik7CiAgICB9Cn0KCm1hcDxzdHJpbmcsIGludD4gbTsKCnN0cmluZyBhdFsxMl07CgpzdHJpbmcgYXJyWzExXVsyMDFdOwoKaW50IGNvdW50c1sxMV0gPSB7MH07Cgp2ZWN0b3I8c3RyaW5nPiBhbnNbMTFdOwoKaW50IGNudCA9IDE7Cgpib29sIGNtcChzdHJpbmcmIHMxLCBzdHJpbmcmIHMyKXsKICAgIHJldHVybiBzMS5zaXplKCkgPiBzMi5zaXplKCk7Cn0KCnZvaWQgYnVpbGQoKXsKICAgIGludCBuOwogICAgY2luID4+IG47CiAgICB3aGlsZShuLS0pewogICAgICAgIHN0cmluZyBuYW1lOwogICAgICAgIGNpbiA+PiBuYW1lOwogICAgICAgIGludCBwb3MgPSAwOwogICAgICAgIGlmKG1bbmFtZV0pIHBvcyA9IG1bbmFtZV07CiAgICAgICAgZWxzZXsgbVtuYW1lXSA9IGNudDsgcG9zID0gY250OyBhdFtjbnRdID0gbmFtZTsgY250Kys7ICB9CiAgICAKICAgICAgICBpbnQgbnVtOwogICAgICAgIGNpbiA+PiBudW07CiAgICAgICAgd2hpbGUobnVtLS0pewogICAgICAgICAgICBzdHJpbmcgczsKICAgICAgICAgICAgY2luID4+IHM7CiAgICAgICAgICAgIGFycltwb3NdW2NvdW50c1twb3NdKytdID0gczsKICAgICAgICB9CiAgICB9CiAgICAKICAgIGZvcihpbnQgaiA9IDE7IGogPCBjbnQ7IGorKykKICAgICAgICBzb3J0KGFycltqXSwgYXJyW2pdICsgY291bnRzW2pdLCBjbXApOwp9Cgp2b2lkIHNvbHZlKCl7CiAgICBmb3IoaW50IGogPSAxOyBqIDwgY250OyBqKyspewogICAgICAgIG5vZGUqIHJvb3QgPSBuZXcgbm9kZTsKICAgICAgICBmb3IoaW50IGsgPSAwOyBrIDwgY291bnRzW2pdOyBrKyspCiAgICAgICAgICAgIGlmKGFkZChyb290LCBhcnJbal1ba10sIDAsIGFycltqXVtrXS5sZW5ndGgoKSkpIGFuc1tqXS5wdXNoX2JhY2soYXJyW2pdW2tdKTsKICAgIH0KfQoKaW50IG1haW4oKXsKICAgIGJ1aWxkKCk7CiAgICBjb3V0IDw8ICJidWlsZGVyIGNvbXBsZXRlIVxuIjsKICAgIHNvbHZlKCk7CgogICAgY291dCA8PCAoY250LTEpIDw8IGVuZGw7CiAgICBmb3IoaW50IGogPSAxOyBqIDwgY250OyBqKyspewogICAgICAgIGNvdXQgPDwgYXRbal0gPDwgIiAiOwogICAgICAgIGNvdXQgPDwgYW5zW2pdLnNpemUoKSA8PCAiICI7CiAgICAgICAgZm9yKGludCBrID0gMDsgayA8IGFuc1tqXS5zaXplKCk7IGsrKykKICAgICAgICAgICAgY291dCA8PCBhbnNbal1ba10gPDwgIiAiOwogICAgICAgIGNvdXQgPDwgZW5kbDsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==