def r;read_line.split.map &.to_i;end n,m=r a=r g=a.map{[]of Int32} m.times{ u,v=r.map &.pred g[v]<a[v] g[u]<a[u] } r f=[0]*n r.each{|i|f[i-1]=1} ans=(0...n).to_a.sort_by{|i|a[i]}.select{|i| if f[i]>0 f[i]=0 g[i].map{|j|f[j]^=1} end } if f.all? 0 puts ans.size,ans.join '\n',&.succ else p -1 end