#!/bin/python3 import sys def canConstruct(a): res = 0 for num in a: for c in num: res += int(c) % 3 return res % 3 == 0 if __name__ == "__main__": t = int(input().strip()) for a0 in range(t): n = int(input().strip()) a = list(input().strip().split(' ')) result = canConstruct(a) if(result): print("Yes") else: print("No")