from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum from heapq import heapify, heappop, heappush from bisect import bisect_left, bisect_right from copy import deepcopy import copy import random from random import randrange from collections import deque,Counter,defaultdict from itertools import permutations,combinations from decimal import Decimal,ROUND_HALF_UP #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP) from functools import lru_cache, reduce #@lru_cache(maxsize=None) from operator import add,sub,mul,xor,and_,or_,itemgetter import sys input = sys.stdin.readline # .rstrip() INF = 10**18 mod1 = 10**9+7 mod2 = 998244353 #DecimalならPython #再帰ならPython!!!!!!!!!!!!!!!!!!!!!!!!!! def calc(N,S): t = [] for s in S: if s == "?": t.append(2) else: t.append(int(s)) for init in range(4): flag = True for i in range(2): if t[i] == 2 or t[i] == ((init >> (1 - i)) & 1): pass else: flag = False if flag == False: continue dat = [0] * 4 dat[init] = 1 for j in range(2,N): nx = [0] * 4 if t[j] == 2 or t[j] == 1: for bit in range(3): nx [((bit << 1) | 1) & 3] |= dat[bit] if t[j] == 2 or t[j] == 0: for bit in range(1,4): nx [(bit << 1) & 3] |= dat[bit] dat = nx for bit in range(4): if dat[bit]: flag = True tmp = (bit << 1) | (init >> 1) if tmp == 0 or tmp == 7: flag = False else: pass tmp = ((bit & 1) << 2) | init if tmp == 0 or tmp == 7: flag = False else: pass if flag: #print(bit,tmp,init) return True return False ''' dpだとは思う 直前の二個を記録すればいいかな 1周回ってきたときに、最初の?をなにで解釈したか考えないといけない 最初の?が1じゃないとダメなとき、11が後ろにあったらダメ 3文字メモしておかないとだめ? ''' for _ in range(int(input())): N = int(input()) S = list(input().rstrip()) dp = [[[[0]*2 for _ in range(2)] for _ in range(2)] for _ in range(N+1)] for i in range(2): for j in range(2): for k in range(2): dp[0][i][j][k] = 1 for i in range(1,N+1): if S[i-1] == '0': for j in range(2): for k in range(2): for l in range(2): if j == k == 0: continue dp[i][j][k][0] = max(dp[i][j][k][0], dp[i-1][l][j][k]) elif S[i-1] == '1': for j in range(2): for k in range(2): for l in range(2): if j == k == 1: continue dp[i][j][k][1] = max(dp[i][j][k][1], dp[i-1][l][j][k]) else: for j in range(2): for k in range(2): for l in range(2): if j == k == 0: continue dp[i][j][k][0] = max(dp[i][j][k][0], dp[i-1][l][j][k]) for j in range(2): for k in range(2): for l in range(2): if j == k == 1: continue dp[i][j][k][1] = max(dp[i][j][k][1], dp[i-1][l][j][k]) f = 0 for i in range(2): for j in range(2): for k in range(2): if dp[N][i][j][k] == 1: if j == k: for l in range(2): for m in range(2): if dp[3][(j+1)%2][l][m] == 1: f = 1 else: for l in range(2): for m in range(2): if dp[3][m][(m+1)%2][l] == 1: f = 1 if f: print('Yes') else: print('No')