n = int(eval(input()))

a = int(eval(input()))



q = n % 500



if a >= q:

  print('Yes')

else:

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

a =int(eval(input()))

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

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

-q = n % 500 -if a >= q: -    print("Yes") -else: -    print("No") +print(("Yes" if n % 500 <= a else "No"))