t = input(); for __t in range (t): n = input() n = raw_input() sum = 0 for i in n: if '0'<=i and i<='9': sum+=int( int(i) - 48) print "Yes" if sum%3==0 else "No"