#include // clang-format off using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair; const ll INF=4e18; void print0(){}; template void print0(H h,T... t){cout<void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);} void perr0(){}; template void perr0(H h,T... t){cerr<void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);} void ioinit() { cout<> N; vector> colors(3, vector(N + 1)); unordered_set colorset; for (ll i = 0; i < N; i++) { char c; ll d; cin >> c >> d; ll cc = 0; if (c == 'R') cc = 0; if (c == 'G') cc = 1; if (c == 'B') cc = 2; colorset.insert(cc); colors[cc][d]++; } vector kinds(8); for (ll i = 1; i <= N; i++) { ll kind = 0; for (ll c = 0; c < 3; c++) { if (colors[c][i]) { kind += 1 << c; } } kinds[kind]++; } ll one = (kinds[1] > 0) + (kinds[2] > 0) + (kinds[4] > 0); ll two = (kinds[3] > 0) + (kinds[5] > 0) + (kinds[6] > 0); ll three = (kinds[7] > 0); ll all_color = colorset.size(); if (all_color == 1) { return true; } if (all_color == 2) { if (two) return true; return false; } if (three) { if (two) return true; if (kinds[7] >= 2) return true; if (one <= 2) return true; return false; } if (two >= 2) return true; return false; } int main() { ioinit(); ll T; cin >> T; while (T--) { print(solve() ? "YES" : "NO"); } return 0; }