T = int(input()) for _ in range(T): N = int(input()) A = list(map(str,input().split())) C = "".join(A) BB = [] for ii,vv in enumerate(C): if vv != "1": BB.append(vv) B = "".join(BB) if "22" in B or "00" in B: print("No") continue if B.find("0") == -1 or B.find("2") == -1: print("No") continue if B.count("2") != B.count("0"): print("No") continue if B[0] == "0" and B[-1] == "0": print("No") continue if B[0] == "2" and B[-1] == "2": print("No") continue cnt = 0 for ii,vv in enumerate(A): cnt += int(vv) if cnt != N: print("No") continue print("Yes")