def solve(): n = int(input()) colors = [set() for _ in range(n)] for _ in range(n): c, d = input().split() d = int(d) d -= 1 colors[d].add(c) count_r = 0 count_g = 0 count_b = 0 rg = 0 gb = 0 br = 0 rgb = 0 for cs in colors: if 'R' in cs: count_r += 1 if 'G' in cs: count_g += 1 if 'B' in cs: count_b += 1 if cs == {'R', 'G'}: rg = 1 if cs == {'G', 'B'}: gb = 1 if cs == {'B', 'R'}: br = 1 if cs == {'R', 'G', 'B'}: rgb += 1 # 1 color if count_r + count_g == 0 or count_g + count_b == 0 or count_b + count_r == 0: return True # 2 colors if count_r == 0 or count_g == 0 or count_r == 0: return rg + gb + br > 0 # 3 colors if rg + gb + br + rgb >= 2: return True if rgb == 0: return False return count_r == 1 or count_g == 1 or count_b == 1 t = int(input()) for _ in range(t): if solve(): print('YES') else: print('NO')