(n,m),a,*q=$<.map{|e|e.split.map &:to_i} h=Hash.new{|h,k|h[k]=[]} q.each{|u,v|h[u-1]<a[e] } x*~-x/2+y*~-y/2>0 } ? :YES : :NO