import sys from sys import stdin CtoI = {} CtoI["B"] = 0 CtoI["G"] = 1 CtoI["R"] = 2 TT = int(stdin.readline()) ANS = [] for loop in range(TT): N = int(stdin.readline()) DC = {} cset = set() for i in range(N): C,D = stdin.readline()[:-1].split() if D not in DC: DC[D] = [0,0,0] DC[D][CtoI[C]] = 1 cset.add(C) same = [0] * 3 for D in DC: bgr = DC[D] if bgr[0] == bgr[1] == 1: same[0] = 1 if bgr[1] == bgr[2] == 1: same[1] = 1 if bgr[2] == bgr[0] == 1: same[2] = 1 #print (cset,same) if len(cset) == 1: ANS.append("YES") elif len(cset) == 2: if sum(same) > 0: ANS.append("YES") else: ANS.append("NO") else: if sum(same) >= 2: ANS.append("YES") else: ANS.append("NO") print(*ANS, sep="\n") # print ("\n".join(map(str,ANS)))