T = int(input()) for i in range(T): N = int(input()) S = input() count0 = 0 count1 = 0 result = 'Yes' for l in range(N+2): if l >= N : l -= N l = S[l] if l == '0': count0 += 1 count1 = 0 elif l == '1': count1 += 1 count0 = 0 else: if count1 > 0: count0 += 1 count1 = 0 elif count0 > 0: count1 += 1 count0 = 0 if count0 == 3 or count1 == 3: result = 'No' print(result)