#include #include #include #include #include #include #include using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<1000000007>; bool testcase(){ int N; cin >> N; vector> colors(3); rep(i,N){ char c; int d; cin >> c >> d; if(c == 'R') colors[0].push_back(d); if(c == 'G') colors[1].push_back(d); if(c == 'B') colors[2].push_back(d); } rep(c,3) sort(colors[c].begin(), colors[c].end()); colors.erase(remove_if(colors.begin(), colors.end(), [](const vector& a){return a.empty();}), colors.end()); if(colors.size() == 1) return true; if(colors.size() == 2){ for(int c : colors[0]) if(binary_search(colors[1].begin(), colors[1].end(), c)) return true; return false; } rep(i,3){ if(colors[1].size() > 1){ vector a0, a2; rep(c,colors[1].size()) if(binary_search(colors[0].begin(), colors[0].end(), colors[1][c])) a0.push_back(c); rep(c,colors[1].size()) if(binary_search(colors[2].begin(), colors[2].end(), colors[1][c])) a2.push_back(c); if(!a0.empty() && !a2.empty()){ if(a0.size() > 1) return true; if(a2.size() > 1) return true; if(a0 != a2) return true; } } else { vector a0, a2; rep(c,colors[1].size()) if(binary_search(colors[0].begin(), colors[0].end(), colors[1][c])) a0.push_back(c); rep(c,colors[1].size()) if(binary_search(colors[2].begin(), colors[2].end(), colors[1][c])) a2.push_back(c); if(!a0.empty() && !a2.empty()) return true; } swap(colors[0], colors[1]); swap(colors[1], colors[2]); } return false; } int main(){ int T; cin >> T; rep(i,T){ auto ans = testcase(); cout << (ans ? "YES\n" : "NO\n"); } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;