n = list(map(int, eval(input())))

print(("Yes" if sum(n) % 9 == 0 else "No"))

print(("Yes" if sum(map(int, eval(input()))) % 9 == 0 else "No"))

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

print(("Yes" if sum(map(int, eval(input()))) % 9 == 0 else "No"))

-n = list(map(int, eval(input()))) -print(("Yes" if sum(n) % 9 == 0 else "No")) +print(("Yes" if sum(map(int, eval(input()))) % 9 == 0 else "No"))