T=int(input()) for _ in range(T): N=int(input()) A=list(map(int,input().split())) now=0 judge=True allone=True for i in range(N): if A[i]==2: now+=1 allone=False elif A[i]==0: now-=1 allone=False if now>=2 or now<=-2: judge=False break if allone: judge=False if judge: print("Yes") else: print("No")