N = int(eval(input()))

A = int(eval(input()))



amari = N % 500



if amari <= A:

    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()))
amari = N % 500
if amari <= A:
    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())) -amari = N % 500 -if amari <= A: +n = int(eval(input())) +a = int(eval(input())) +if n % 500 <= a: