def main(): for _ in range(int(input())): N = int(input()) cards = [list(input().split()) for _ in range(N)] r_cards = filter(lambda card: card[0] == "R", cards) g_cards = filter(lambda card: card[0] == "G", cards) b_cards = filter(lambda card: card[0] == "B", cards) r_nums = set(map(lambda card: int(card[1]), r_cards)) g_nums = set(map(lambda card: int(card[1]), g_cards)) b_nums = set(map(lambda card: int(card[1]), b_cards)) rg_common = r_nums & g_nums gb_common = g_nums & b_nums br_common = b_nums & r_nums if max(map(len, (r_nums, b_nums, g_nums))) == sum(map(len, (r_nums, b_nums, g_nums))): print("YES") continue if len(tuple(filter(lambda elm: len(elm) >= 2, (rg_common, gb_common, br_common)))) >= 2: print("YES") continue if max(map(len, (rg_common, gb_common, br_common))) >= 2: if sum(map(len, (rg_common, gb_common, br_common))) - max(map(len, (rg_common, gb_common, br_common))) > 0: print("YES") elif min(map(len, (r_nums, b_nums, g_nums))) == 0: print("YES") else: print("NO") continue if max(map(len, (rg_common, gb_common, br_common))) == 1: if sum(map(len, (rg_common, gb_common, br_common))) == 3: if rg_common & gb_common: if all(len(nums) > 1 for nums in (r_nums, g_nums, b_nums)): print("NO") else: print("YES") else: print("YES") elif sum(map(len, (rg_common, gb_common, br_common))) == 2: print("YES") elif min(map(len, (r_nums, b_nums, g_nums))) == 0: print("YES") else: print("NO") continue print("NO") if __name__ == "__main__": main()