n = int(eval(input()))

if n%9==0:

  print("Yes")

else:

  print("No")
N = eval(input())

res = 0

for i in range(len(N)):

    res += int(N[i])

if res%9==0:

    print("Yes")

else:

    print("No")
n = int(eval(input()))
if n % 9 == 0:
    print("Yes")
else:
    print("No")

N = eval(input())
res = 0
for i in range(len(N)):
    res += int(N[i])
if res % 9 == 0:
    print("Yes")
else:
    print("No")

-n = int(eval(input())) -if n % 9 == 0: +N = eval(input()) +res = 0 +for i in range(len(N)): +    res += int(N[i]) +if res % 9 == 0: