#!/bin/python import sys from itertools import permutations def canConstruct(a): # Return "Yes" or "No" denoting whether you can construct the required number. numbers = map(int, [''.join(p) for p in permutations(a)]) for n in numbers: if n % 3 == 0: return 'Yes' return 'No' if __name__ == "__main__": t = int(raw_input().strip()) for a0 in xrange(t): n = int(raw_input().strip()) a = raw_input().replace(' ', '') result = canConstruct(a) print result