n = int(eval(input()))

a = int(eval(input()))

if n % 500 <= a:

    print('Yes')

else:

    print('No')
if int(eval(input())) % 500 <= int(eval(input())):

    print('Yes')

else:

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

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

-n = int(eval(input())) -a = int(eval(input())) -if n % 500 <= a: +if int(eval(input())) % 500 <= int(eval(input())):