import sys input = sys.stdin.readline from collections import * def f(c): if c=='R': return 0 elif c=='G': return 1 else: return 2 def solve(): N = int(input()) S = [set() for _ in range(3)] for i in range(N): C, D = input().split() S[f(C)].add(D) v, e = 0, 0 for i in range(3): if len(S[i])>0: v += 1 for j in range(i+1, 3): if len(S[i]&S[j])>0: e += 1 if e>=v-1: print('YES') else: print('NO') for _ in range(int(input())): solve()