E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.
N = int(input()) % 500
print(['NO', 'YES'][int(input()) >= N])
N = int(input()) % 500
print(['No', 'Yes'][int(input()) >= N])