# Enter your code here. Read input from STDIN. Print output to STDOUT for t in range(int(raw_input())): n=int(raw_input()) y=raw_input().split() res=0 for i in y: for j in i: res+=int(j) if res%3==0: print "Yes" else: print "No"