#include<bits/stdc++.h>
using namespace std;
int T;
int n;
string s;
struct Node{
Node* t[10];
char c;
int x;
Node(char tt='\0'){
x=0;
c=tt;
memset(t,0,sizeof(t));
}
}*root;
void del(Node* p){
if(p==nullptr) return;
for(int i=0;i<10;i++){
del(p->t[i]);
}
delete p;
}
bool flag;
void build(Node* p,int step){
if(step>=s.size()){
p->x++;
if(p->x>1) flag=1;
return;
}
if(p->x>0) flag=1;
int c=s[step]-'0';
if(p->t[c]==nullptr){
Node* t=new Node(c+'0');
p->t[c]=t;
}
build(p->t[c],step+1);
}
int main(){
scanf("%d",&T);
while(T--){
flag=0;
del(root);
root=new Node();
scanf("%d",&n);
while(n--){
cin>>s;
build(root,0);
}
if(!flag) printf("YES\n");
else printf("NO\n");
}
return 0;
}