import sys from sys import stdin TT = int(stdin.readline()) ANS = [] for loop in range(TT): N = int(stdin.readline()) DC = [] for i in range(N): C,D = stdin.readline()[:-1].split() DC.append( (D,C) ) DC.sort() cset = set() for i in range(N): cset.add(DC[i][1]) same = [0] * 3 for i in range(N-1): d1,c1 = DC[i] d2,c2 = DC[i+1] if d1 == d2: cs = (c1,c2) if "B" in cs and "G" in cs: same[0] = 1 if "G" in cs and "R" in cs: same[1] = 1 if "R" in cs and "B" in cs: same[2] = 1 if len(cset) == 1: ANS.append("YES") elif len(cset) == 2: if sum(same): ANS.append("YES") else: ANS.append("NO") else: if sum(same) >= 2: ANS.append("YES") else: ANS.append("NO") print ("\n".join(ANS))