f=lambda:map(int,input().split()) n,m=f() *h,=f() G=[[]for _ in[0]*n] for _ in[0]*m: a,b=f();a-=1;b-=1 if h[a]