t=input() for _ in range(t): n=input() a=list(map(int,raw_input().split())) ans=0 for i in a: while i: ans+=i%10 i/=10 if ans%3==0: print "Yes" else: print "No"