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