n = int(eval(input()))

a = int(eval(input()))

d500 = n%500

if a >= d500:

    print("Yes")

else:

    print("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()))
d500 = n % 500
if a >= d500:
    print("Yes")
else:
    print("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())) -d500 = n % 500 -if a >= d500: +N = int(eval(input())) +A = int(eval(input())) +if N % 500 <= A: