#include int main () { int t = 0; int n = 0; char c[2] = ""; int d = 0; int res = 0; int flag[200000] = {}; char cmap[3] = { 'B', 'G', 'R' }; res = scanf("%d", &t); while (t > 0) { int cnt[8] = {}; int b = 0; int ccnt[3] = {}; res = scanf("%d", &n); for (int i = 0; i < n; i++) { flag[i] = 0; } for (int i = 0; i < n; i++) { res = scanf("%s", c); res = scanf("%d", &d); d--; for (int j = 0; j < 3; j++) { if (c[0] == cmap[j]) { flag[d] |= (1< 1 || (cnt[7] > 0 && (ccnt[0] <= 1 || ccnt[1] <= 1 || ccnt[2] <= 1 || cnt[3] > 0 || cnt[5] > 0 || cnt[6] > 0)) || (cnt[3] > 0 && (cnt[5] > 0 || cnt[6] > 0)) || (cnt[5] > 0 && cnt[6] > 0))) || (b != 7 && cnt[b] > 0)) { printf("YES\n"); } else { printf("NO\n"); } t--; } return 0; }