I=lambda:map(int,input().split()) n,m=I() *h,=I() *e,=eval("[],"*n) for i in[0]*m: a,b=I() if h[a-1]