from collections import deque N,M = map(int,input().split()) A = [0]+list(map(int,input().split())) G = {i:[] for i in range(1,N+1)} indeg = [0]*(N+1) for _ in range(M): u,v = map(int,input().split()) if A[u]>A[v]: G[v].append(u) indeg[u] += 1 if A[u]