import sys #input = sys.stdin.readline #input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) import math import bisect #import itertools #import random #from heapq import heapify, heappop, heappush from collections import defaultdict from collections import deque #import copy #DeepCopy: hoge = [_[:] for _ in hogehoge] #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] #dx8 = [1,1,0,-1,-1,-1,0,1] #dy8 = [0,1,1,1,0,-1,-1,-1] def main(): T = int(input()) for _ in range(T): N = int(input()) dic = defaultdict(list) R = set([]); G = set([]); B = set([]) for i in range(N): c,d = input().split() d = int(d) dic[d].append(c) if c == 'R': R.add(d) if c == 'G': G.add(d) if c == 'B': B.add(d) RGB = set([]) RG = set([]); GB = set([]); BR = set([]) for v,L in dic.items(): if len(L) == 3: RGB.add(v) elif len(L) == 2: if 'R' in L and 'G' in L: RG.add(v) if 'G' in L and 'B' in L: GB.add(v) if 'B' in L and 'R' in L: BR.add(v) # 1色のみの場合 if len(G) == len(B) == 0: print('YES') elif len(B) == len(R) == 0: print('YES') elif len(R) == len(G) == 0: print('YES') # 2色のみの場合 elif len(R) == 0: if len(GB) >= 1: print('YES') else: print('NO') elif len(G) == 0: if len(BR) >= 1: print('YES') else: print('NO') elif len(B) == 0: if len(RG) >= 1: print('YES') else: print('NO') # 3色ある場合 elif len(RGB) >= 2: print('YES') elif len(RGB) == 1: if len(RG) >= 1 or len(GB) >= 1 or len(BR) >= 1: print('YES') else: print('NO') else: if len(RG) >= 1 and len(GB) >= 1: print('YES') elif len(GB) >= 1 and len(BR) >= 1: print('YES') elif len(BR) >= 1 and len(RG) >= 1: print('YES') else: print('NO') if __name__ == '__main__': main()