import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 import random def solve(): n = ii() s = input() for i in range(50): x = i s = s[x:] + s[:x] if '000' in s or '111' in s or '00?11' in s or '11?00' in s: print('No') return print('Yes') for _ in range(ii()): solve()