#include<bits/stdc++.h>
using namespace std;
struct node{
int cnt_trees;
node *next[10];
node(){
cnt_trees=0;
for(int i=0;i<10;i++)next[i]=NULL;
}
}*root;
void insert_into_Trie(string str){
node *cur=root;
for(int i=0;str[i];i++){
int id=str[i]-'0';
if(cur->next[id]==NULL)
cur->next[id]=new node();
cur=cur->next[id];
}
cur->cnt_trees++;
//cout<<cur->cnt_trees<<endl;
}
bool search(string str){
node *cur=root;
for(int i=0;str[i];i++){
int id=str[i]-'0';
cur=cur->next[id];
}
if(cur->cnt_trees>1) return true; //inconsistent
for(int i=0;i<10;i++){
if(cur->next[i]!=NULL) return true; //inconsistent
}
return false; //not yet inconsistent
}
void del(node* cur)
{
for(int i= 0;i<10;i++)
if (cur->next[i])
del(cur->next[i]);
delete(cur);
}
int main()
{
int tc,cs=0;
string str;
scanf("%d",&tc);
while(tc--){
root=new node();
int n,f=1;
scanf("%d",&n);
vector<string>v;
getchar();
while(n--){
cin>>str;
insert_into_Trie(str);
v.push_back(str);
}
cout<<"Case "<<++cs<<": ";
for(int i=0;i<v.size();i++){
if(search(v[i])){
cout<<"NO"<<endl;f=0;break;
}
}
if(f) cout<<"YES"<<endl;
del(root);
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKc3RydWN0IG5vZGV7CiAgICBpbnQgY250X3RyZWVzOwogICAgbm9kZSAqbmV4dFsxMF07CiAgICBub2RlKCl7CiAgICAgICAgY250X3RyZWVzPTA7CiAgICAgICAgZm9yKGludCBpPTA7aTwxMDtpKyspbmV4dFtpXT1OVUxMOwogICAgfQp9KnJvb3Q7Cgp2b2lkIGluc2VydF9pbnRvX1RyaWUoc3RyaW5nIHN0cil7CiAgICBub2RlICpjdXI9cm9vdDsKICAgIGZvcihpbnQgaT0wO3N0cltpXTtpKyspewogICAgICAgIGludCBpZD1zdHJbaV0tJzAnOwogICAgICAgIGlmKGN1ci0+bmV4dFtpZF09PU5VTEwpCiAgICAgICAgICAgIGN1ci0+bmV4dFtpZF09bmV3IG5vZGUoKTsKICAgICAgICAgICAgY3VyPWN1ci0+bmV4dFtpZF07CiAgICB9CiAgICBjdXItPmNudF90cmVlcysrOwogICAgLy9jb3V0PDxjdXItPmNudF90cmVlczw8ZW5kbDsKfQoKYm9vbCBzZWFyY2goc3RyaW5nIHN0cil7CiAgICBub2RlICpjdXI9cm9vdDsKICAgIGZvcihpbnQgaT0wO3N0cltpXTtpKyspewogICAgICAgIGludCBpZD1zdHJbaV0tJzAnOwogICAgICAgIGN1cj1jdXItPm5leHRbaWRdOwogICAgfQogICAgaWYoY3VyLT5jbnRfdHJlZXM+MSkgcmV0dXJuIHRydWU7ICAgLy9pbmNvbnNpc3RlbnQKICAgIGZvcihpbnQgaT0wO2k8MTA7aSsrKXsKICAgICAgICBpZihjdXItPm5leHRbaV0hPU5VTEwpIHJldHVybiB0cnVlOyAvL2luY29uc2lzdGVudAogICAgfQogICAgcmV0dXJuIGZhbHNlOyAgLy9ub3QgeWV0IGluY29uc2lzdGVudAp9Cgp2b2lkIGRlbChub2RlKiBjdXIpCnsKICAgIGZvcihpbnQgaT0gMDtpPDEwO2krKykKICAgICAgICBpZiAoY3VyLT5uZXh0W2ldKQogICAgICAgICAgICBkZWwoY3VyLT5uZXh0W2ldKTsKCiAgICBkZWxldGUoY3VyKTsKfQoKaW50IG1haW4oKQp7CiAgICBpbnQgdGMsY3M9MDsKICAgIHN0cmluZyBzdHI7CiAgICBzY2FuZigiJWQiLCZ0Yyk7CiAgICB3aGlsZSh0Yy0tKXsKICAgICAgICByb290PW5ldyBub2RlKCk7CiAgICAgICAgaW50IG4sZj0xOwogICAgICAgIHNjYW5mKCIlZCIsJm4pOwogICAgICAgIHZlY3RvcjxzdHJpbmc+djsKICAgICAgICBnZXRjaGFyKCk7CiAgICAgICAgd2hpbGUobi0tKXsKICAgICAgICAgICAgY2luPj5zdHI7CiAgICAgICAgICAgIGluc2VydF9pbnRvX1RyaWUoc3RyKTsKICAgICAgICAgICAgdi5wdXNoX2JhY2soc3RyKTsKICAgICAgICB9CiAgICAgICAgY291dDw8IkNhc2UgIjw8Kytjczw8IjogIjsKICAgICAgICBmb3IoaW50IGk9MDtpPHYuc2l6ZSgpO2krKyl7CiAgICAgICAgICAgIGlmKHNlYXJjaCh2W2ldKSl7CiAgICAgICAgICAgICAgICBjb3V0PDwiTk8iPDxlbmRsO2Y9MDticmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZihmKSBjb3V0PDwiWUVTIjw8ZW5kbDsKICAgICAgICBkZWwocm9vdCk7CiAgICB9CiAgICByZXR1cm4gMDsKfQo=