def solve(): N = int(input()) S = input() if S == "1": print("Yes") return print("Yes" if (S.count("0")+2*S.count("1"))%3 == 2 and S != "01"*(N//2)+("0" if N%2 else "") and S != "10"*(N//2)+("1" if N%2 else "") else "No") for i in range(int(input())): solve()