a = int(eval(input()))

b = int(eval(input()))

a = a % 500

if a > b:

 print("No")

else:

 print("Yes")
n = int(eval(input()))

a = int(eval(input()))

n %= 500

if n <= a:

  print("Yes")

else:

  print("No")
a = int(eval(input()))
b = int(eval(input()))
a = a % 500
if a > b:
    print("No")
else:
    print("Yes")

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

+n = int(eval(input())) -b = int(eval(input())) -a = a % 500 -if a > b: +n %= 500 +if n <= a: +    print("Yes") +else: -else: -    print("Yes")