import sys import itertools t = int(raw_input()) for a0 in xrange(t): d = int(raw_input()) inp = map(int, raw_input().strip().split()) x = ''.join(map(str, inp)) y = list(itertools.permutations(x)) count = 0 for i in range(len(y)): num = ''.join(map(str, y[i])) if int(num) % 3 == 0: count = count + 1 if count >= 1: print 'Yes' else: print 'No'