T = int(input()) for _ in range(T): N = int(input()) A = list(map(str,input().split())) B = "".join(A) if "22" in B or "00" in B: print("No") continue if B.find("0") == -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")