$%=1e3;map{$G%=$%if(($G//=$')-=$_*=$%/=--$|?2:5)<0}<>=~/\d+ /g;print$G?NO:YES