N = int(eval(input()))

A = int(eval(input()))

print(("Yes" if N % 500 <= A else "No"))

print(("Yes" if int(eval(input())) % 500 <= int(eval(input())) else "No"))

N = int(eval(input()))
A = int(eval(input()))
print(("Yes" if N % 500 <= A else "No"))

print(("Yes" if int(eval(input())) % 500 <= int(eval(input())) else "No"))

-N = int(eval(input())) -A = int(eval(input())) -print(("Yes" if N % 500 <= A else "No")) +print(("Yes" if int(eval(input())) % 500 <= int(eval(input())) else "No"))