#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;
}
