#include <bits/stdc++.h>

using namespace std;

struct node {
	node* next[10];
	int cnt = 0;
	node() {
		for (int i = 0; i < 10; i++)
			next[i] = nullptr;
		cnt = 0;
	}
};

node* root = new node();

void add(string& s) {
	node* now = root;
	for (int i = 0; i < (int)s.size(); i++) {
		if (now -> next[s[i] - '0'] == nullptr)
			now -> next[s[i] - '0'] = new node();
		now = now -> next[s[i] - '0'];
	}	 
	now -> cnt += 1;
}

bool flag = true;

void dfs(node* now = root, int was = 0) {
	if (now -> cnt && was) flag = false;
	for (int i = 0; i < 10; i++) {
		if (now -> next[i] != nullptr) {
			dfs(now -> next[i], max(now -> cnt, was));
		}  	
	}
}

int main() {
	int t;
	cin >> t;
	while(t--) {
		root = new node();
		int n;
		cin >> n;
		while(n--) {
			string s;
			cin >> s;
			add(s);
		}
		flag = true;
		dfs();
		if (flag)
			cout << "YES\n";
		else
			cout << "NO\n";
	}
	return 0;
}
     