def solve(): n = int(input()) S = input() for i in range(2): for j in range(2): dp = [False] * 4 if str(1 - i) == S[0] or str(1 - j) == S[1]: continue dp[2 * i + j] = True for s in S[2:]: ndp = [False] * 4 if s != "1": nex = 0 for ii in range(2): for jj in range(2): if nex == ii == jj: continue ndp[2 * jj + nex] |= dp[2 * ii + jj] if s != "0": nex = 1 for ii in range(2): for jj in range(2): if nex == ii == jj: continue ndp[2 * jj + nex] |= dp[2 * ii + jj] dp = ndp for ii in range(2): for jj in range(2): if ii == jj == i or jj == i == j: continue if dp[2 * ii + jj]: return True return False for _ in range(int(input())): if solve(): print("Yes") else: print("No")