E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.
a=int(input())
b=int(input())
if (a*500)<=b:
  print("Yes")
else:
  print("No")
a=int(input())
b=int(input())
if (a%500)<=b:
  print("Yes")
else:
  print("No")