#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while(t--){
int n;
cin >> n;
string s[n];
int flag(0);
for(int i=0;i<n;i++){
cin >> s[i];
}
for(int i=0;i<n;i++){
if(s[i].length() == 3 && s[i][0] == s[i][2]){
flag = 1;
break;
}
}
for(int i=0;i<n;i++){
if(s[i].length() == 1){
flag =1;
break;
}
int flag1(0);
for(int j=0;j<s[i].length();j++){
if(s[i][j] != s[i][0]){
flag1 = 1;
break;
}
}
if(flag1 == 0){
flag = 1;
}
}
if(flag == 1){
cout << "YES" << endl;
}
else{
set<string> s2;
set<string> s3;
for(int i=0;i<n;i++){
if(s[i].length() == 2){
string x = s[i];
reverse(x.begin(),x.end());
if(s2.find(x) != s2.end()){
flag = 1;
break;
}
s2.insert(s[i]);
}
if(s[i].length() == 3){
string x = s[i];
reverse(x.begin(),x.end());
if(s3.find(x) != s3.end()){
flag = 1;
break;
}
s3.insert(s[i]);
string y;
y += s[i][2];
y += s[i][1];
// cout << y << endl;
if(s2.find(y) != s2.end()){
flag = 1;
break;
}
}
}
if(flag == 1){
cout << "YES" << endl;
}
else{
set<string> fin;
for(int i=n-1;i>-1;i--){
if(s[i].length() == 2){
fin.insert(s[i]);
}
if(s[i].length() == 3){
string zz;
zz += s[i][1];
zz += s[i][0];
if(fin.find(zz) != fin.end()){
flag = 1;
break;
}
}
}
if(flag == 1){
cout << "YES" << endl;
}
else{
cout << "NO" << endl;
}
}
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCB0OwoJY2luID4+IHQ7Cgl3aGlsZSh0LS0pewoJCWludCBuOwoJCWNpbiA+PiBuOwoJCXN0cmluZyBzW25dOwoJCWludCBmbGFnKDApOwoJCWZvcihpbnQgaT0wO2k8bjtpKyspewoJCQljaW4gPj4gc1tpXTsKCQl9CgkJZm9yKGludCBpPTA7aTxuO2krKyl7CgkJCWlmKH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