#include<cstdio> #include<algorithm> #include<iostream> #include<cstring> #include<cmath> using namespace std;
typedef long long ll;
struct Trie{ Trie *next[10]; int val; Trie(){ val = 0; for (int i = 0 ; i < 10 ; i ++) next[i] = NULL; } };
bool addword(char *str,Trie* node) {
if (node->val!=0) return false; if (node->next[str[0]-'0']==NULL) node->next[str[0]-'0'] = new Trie; node = node->next[str[0]-'0']; str++; //printf("%d\t",*str); if (*str) return addword(str,node); else { node->val++; return true; } }
int query(char *str ,Trie *node) { // printf("%d\t",*str); if (node->next[*str-'0']==NULL) return 0; else node= node->next[*str-'0']; ++str; if (*str) return query(str,node); else return node->val; }
void del(Trie *node) { for (int i = 0 ; i < 10 ; i ++) { if (node->next[i]!=NULL) del(node->next[i]); } delete node; node = NULL; return; } struct String{ char str[20]; int len; void read() { scanf("%s",str); len = strlen(str); } bool operator <(const String& a) { return len<a.len; } }s[12000];
int main() { int T,n; //printf("hello\n"); Trie *head; //printf("world\n"); scanf("%d",&T);
while (T--) {
scanf("%d",&n); head = new Trie; for (int i = 1; i <= n ; i ++) { s[i].read(); } sort(s+1,s+n+1); int f = 1; //printf("ok\n"); for (int i = 1 ; i <= n ; i ++) { if (!addword(s[i].str,head)) { f = 0; break; } } //printf("fuck\n"); if (!f) printf("NO\n"); else printf("YES\n"); del(head);