#!/bin/python3 import sys,itertools def canConstruct(a): # Return "Yes" or "No" denoting whether you can construct the required number. v = list(itertools.permutations(a)) f = False for item in v: if not int("".join([str(g) for g in item])) % 3: return "Yes" f = True break if not f: 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)