#!/bin/python3 import sys import itertools def canConstruct(a): # Return "Yes" or "No" denoting whether you can construct the required number. h = [str(i) for i in a] x = ''.join(h) l = [i for i in x] n = list(itertools.permutations(l)) g = [int(''.join(i)) for i in n] for i in g: if i%3==0: return "Yes" return "No" 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)