print(("Yes" if int(eval(input()))%9==0 else "No"))
n=sum([int(c) for c in eval(input())])

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

n = sum([int(c) for c in eval(input())])
print(("Yes" if n % 9 == 0 else "No"))

-print(("Yes" if int(eval(input())) % 9 == 0 else "No")) +n = sum([int(c) for c in eval(input())]) +print(("Yes" if n % 9 == 0 else "No"))