import sys # sys.setrecursionlimit(300005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # inf = 4294967295 md = 10**9+7 # md = 998244353 def solve(): n = II() dd = [set(), set(), set()] for _ in range(n): c, d = SI().split() d = int(d) c = "RGB".find(c) dd[c].add(d) for c in range(3)[::-1]: if len(dd[c]) == 0: dd.pop(c) if len(dd) == 1: return True if len(dd) == 2: if dd[0] & dd[1]: return True return False ee = [] for c in range(3): ee.append(dd[c-1] & dd[c]) if sum(len(ee[c]) == 0 for c in range(3)) > 1: return False if len(ee[0] | ee[1] | ee[2]) == 1: return any(len(dd[c]) == 1 for c in range(3)) return True # *************************************** testnumber = II() # testnumber = 1 for testcase in range(testnumber): # solve() print("YES" if solve() else "NO") # print("Yes" if solve() else "No")