E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.
N=int(input())
A=int(input())
n500=N//500
check=N-n500
print("Yes" if check<=A else "No")
N=int(input())
A=int(input())
check=N%500
print("Yes" if check<=A else "No")