for _ in range(int(input())): n = int(input()) A = input() if len(set(A.split())) == 1: print("No") elif n >= 7 or n % 2 == 0: print("Yes") elif "0 0" in A or "1 1" in A: print("Yes") else: print("No")