#include<bits/stdc++.h>
using namespace std;
int total;
struct node{
int cnt_trees;
node *next[128];
node(){
cnt_trees=0;
for(int i=0;i<128;i++) next[i]=NULL;
}
}*root;
void insert_into_Trie(char* str){
node *cur=root;
for(int i=0;str[i];i++){
int id=str[i];
if(cur->next[id]==NULL)
cur->next[id]=new node();
cur=cur->next[id];
}
cur->cnt_trees++;
}
void printTree(node *cur,vector<char>name){
if(cur->cnt_trees){
for(auto x:name){
printf("%c",x);
}
cout<<' '<<setprecision(4)<<fixed<<(100.0*(double)(cur->cnt_trees))/(double)(total)<<endl;
}
for(int i=0;i<128;i++){
if(cur->next[i]!=NULL){
name.push_back(i);
printTree(cur->next[i],name);
name.pop_back();
}
}
name.pop_back();
}
void del(node* cur)
{
for(int i= 0;i<128;i++)
if (cur->next[i])
del(cur->next[i]);
delete(cur);
}
int main()
{
int n,q,tc;
char str[21];
scanf("%d\n\n",&n);
tc=n;
while(n--){
root=new node();
total=0;
while(gets(str)){
if(strlen(str)==0)break;
insert_into_Trie(str);
total++;
}
vector<char>name;
printTree(root,name);
if(--tc)printf("\n");
del(root);
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IHRvdGFsOwpzdHJ1Y3Qgbm9kZXsKICAgIGludCBjbnRfdHJlZXM7CiAgICBub2RlICpuZXh0WzEyOF07CiAgICBub2RlKCl7CiAgICAgICAgY250X3RyZWVzPTA7CiAgICAgICAgZm9yKGludCBpPTA7aTwxMjg7aSsrKSBuZXh0W2ldPU5VTEw7CiAgICB9Cn0qcm9vdDsKCnZvaWQgaW5zZXJ0X2ludG9fVHJpZShjaGFyKiBzdHIpewogICAgbm9kZSAqY3VyPXJvb3Q7CiAgICBmb3IoaW50IGk9MDtzdHJbaV07aSsrKXsKICAgICAgICBpbnQgaWQ9c3RyW2ldOwogICAgICAgIGlmKGN1ci0+bmV4dFtpZF09PU5VTEwpCiAgICAgICAgICAgIGN1ci0+bmV4dFtpZF09bmV3IG5vZGUoKTsKICAgICAgICAgICAgY3VyPWN1ci0+bmV4dFtpZF07CiAgICB9CiAgICBjdXItPmNudF90cmVlcysrOwp9Cgp2b2lkIHByaW50VHJlZShub2RlICpjdXIsdmVjdG9yPGNoYXI+bmFtZSl7CiAgICBpZihjdXItPmNudF90cmVlcyl7CiAgICAgICAgZm9yKGF1dG8geDpuYW1lKXsKICAgICAgICAgICAgcHJpbnRmKCIlYyIseCk7CiAgICAgICAgfQogICAgICAgIGNvdXQ8PCcgJzw8c2V0cHJlY2lzaW9uKDQpPDxmaXhlZDw8KDEwMC4wKihkb3VibGUpKGN1ci0+Y250X3RyZWVzKSkvKGRvdWJsZSkodG90YWwpPDxlbmRsOwogICAgfQoKCiAgICBmb3IoaW50IGk9MDtpPDEyODtpKyspewogICAgICAgIGlmKGN1ci0+bmV4dFtpXSE9TlVMTCl7CiAgICAgICAgICAgIG5hbWUucHVzaF9iYWNrKGkpOwogICAgICAgICAgICBwcmludFRyZWUoY3VyLT5uZXh0W2ldLG5hbWUpOwogICAgICAgICAgICBuYW1lLnBvcF9iYWNrKCk7CiAgICAgICAgfQogICAgfQogICAgbmFtZS5wb3BfYmFjaygpOwp9Cgp2b2lkIGRlbChub2RlKiBjdXIpCnsKICAgIGZvcihpbnQgaT0gMDtpPDEyODtpKyspCiAgICAgICAgaWYgKGN1ci0+bmV4dFtpXSkKICAgICAgICAgICAgZGVsKGN1ci0+bmV4dFtpXSk7CgogICAgZGVsZXRlKGN1cik7Cn0KCmludCBtYWluKCkKewogICAgaW50IG4scSx0YzsKICAgIGNoYXIgc3RyWzIxXTsKICAgIHNjYW5mKCIlZFxuXG4iLCZuKTsKICAgIHRjPW47CiAgICB3aGlsZShuLS0pewogICAgICByb290PW5ldyBub2RlKCk7CiAgICAgIHRvdGFsPTA7CiAgICAgIHdoaWxlKGdldHMoc3RyKSl7CiAgICAgICAgaWYoc3RybGVuKHN0cik9PTApYnJlYWs7CiAgICAgICAgaW5zZXJ0X2ludG9fVHJpZShzdHIpOwogICAgICAgIHRvdGFsKys7CiAgICAgIH0KICAgICAgdmVjdG9yPGNoYXI+bmFtZTsKICAgICAgcHJpbnRUcmVlKHJvb3QsbmFtZSk7CiAgICAgIGlmKC0tdGMpcHJpbnRmKCJcbiIpOwogICAgICBkZWwocm9vdCk7CiAgICB9CiAgICByZXR1cm4gMDsKfQo=