N = eval(input())

A = eval(input())

n = int(N)

a = int(A)





x = n % 500



if x <= a:

	print("Yes")

else:

	print("No")

N = int(eval(input()))

A = int(eval(input()))



num = N % 500



if num <= A:

  print("Yes")

else:

  print("No")



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

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

-N = eval(input()) -A = eval(input()) -n = int(N) -a = int(A) -x = n % 500 -if x <= a: +N = int(eval(input())) +A = int(eval(input())) +num = N % 500 +if num <= A: