I=input O='1' for n in range(int(I())): N,S,f=I(),I(),0 T=[[S,i][S[0]>O][0]+[S,i][S[1]>O][1]for i in["00","01","10","11"]] for t in T: a=b=c=d=1 for s in t+S[2:]+t:a,b,c,d=c*(s!=O),(a+c)*(s>=O),(b+d)*(s!=O),b*(s>=O) f+=a+b+c+d print(["No","Yes"][f>0])