n = int(eval(input()))

a = int(eval(input()))



res = n%500

if res <= a:

  print('Yes')

else:

  print('No')
n = int(eval(input()))

a = int(eval(input()))



n -= (n//500)*500

if n<=a:

  print('Yes')

else:

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

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

-res = n % 500 -if res <= a: +n -= (n // 500) * 500 +if n <= a: