import sys input = sys.stdin.readline def color2int(c: str): if c == "R": return 1 elif c == "G": return 2 elif c == "B": return 4 raise ValueError def solve(N, cards): lst = [0] * N used_color = 0 for c, d in cards: i = color2int(c) lst[d] += i used_color |= i used_color_num = bin(used_color).count("1") ct = [0] * 8 for x in lst: ct[x] += 1 if used_color_num == 1: return True elif used_color_num == 2: return ct[1 | 2] or ct[1 | 4] or ct[2 | 4] else: return ((ct[1 | 2] and ct[1 | 4]) or (ct[1 | 2] and ct[2 | 4]) or (ct[1 | 4] and ct[2 | 4]) or (ct[1 | 2] and ct[1 | 2 | 4]) or (ct[1 | 4] and ct[1 | 2 | 4]) or (ct[2 | 4] and ct[1 | 2 | 4]) or ct[1 | 2 | 4] >= 2 or (ct[1] + ct[1 | 2] + ct[1 | 4] == 0 and ct[1 | 2 | 4]) or (ct[2] + ct[2 | 4] + ct[2 | 1] == 0 and ct[1 | 2 | 4]) or (ct[4] + ct[4 | 1] + ct[4 | 2] == 0 and ct[1 | 2 | 4])) T = int(input()) for _ in range(T): N = int(input()) cards = [] for __ in range(N): c, d = input().split() cards.append((c, int(d) - 1)) print("YES" if solve(N, cards) else "NO")