N=int(eval(input()))

A=int(eval(input()))

if N%500<=A:

    print("Yes")

else:

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

A=int(eval(input()))

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

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

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