#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 bool solve(){ int n; cin>>n; vector> t(3); rep(i,n){ char c; int v; cin>>c>>v; t[(c%3)].push_back(v); } rep(i,3)sort(t[i].begin(),t[i].end()); sort(t.begin(),t.end()); if(t[1].size()==0)return true; if(t[0].size()==0){ rep(i,t[1].size()){ if(binary_search(t[2].begin(),t[2].end(),t[1][i]))return true; } return false; } do{ set S; rep(i,t[0].size()){ if(binary_search(t[1].begin(),t[1].end(),t[0][i]))S.insert(t[0][i]); } if(S.size()==0)continue; rep(i,t[1].size()){ if(binary_search(t[2].begin(),t[2].end(),t[1][i])){ if(S.size()>=2 || t[1].size()==1)return true; if((*S.begin())!=t[1][i])return true; } } } while(next_permutation(t.begin(),t.end())); return false; } int main(){ int _t; cin>>_t; rep(_,_t){ if(solve())cout<<"YES"<