def is_ok(n,s): inf=10**9 for i in range(3): if s[i]!='0' and s[i-1]!='1': t=s[i:]+s[:i] dp=[inf,1] for j in range(1,n): ndp=[inf,inf] if t[j]=='0' or t[j]=='?': ndp[0]=dp[0]+1 if dp[1]<3: ndp[0]=1 if t[j]=='1' or t[j]=='?': ndp[1]=dp[1]+1 if dp[0]<3: ndp[1]=1 dp=ndp if dp[0]<3: return True return False def solve(): n=int(input()) s=list(input()) s2=[] for i in s: if i=='0': s2.append('1') elif i=='1': s2.append('0') else: s2.append('?') if is_ok(n,s) or is_ok(n,s2): print('Yes') else: print('No') for _ in range(int(input())): solve()