#!/bin/python3 import sys import itertools from itertools import permutations def canConstruct(a): temp = str(a) numb=[] #num1=[] for i in range(0,len(temp)): if(temp[i]!=',' and temp[i]!=' ' and temp[i]!=']' and temp[i]!='['): #print(temp[i]) numb+=(temp[i]) #numb = [int(i) for i in numb] #print(numb) for i in list(permutations(numb)): num1=''.join(i) if(int(num1)%3==0): return "Yes" else: return "No" #print(list(permutations(numb))) # Return "Yes" or "No" denoting whether you can construct the required number. #print(list(itertools.combinations(a,len(a)))) if __name__ == "__main__": t = int(input().strip()) for a0 in range(t): n = int(input().strip()) a = list(map(int, input().strip().split(' '))) result = canConstruct(a) print(result)