n=int(input()) m=0 for i in range(n): a=int(input()) for i in range(len(str(a))): m+=a%10 a=a//10 if m%7==0: print('Yes') if m%7!=0: print('No')