from itertools import combinations N,M=map(int,input().split()) A=[0]+list(map(int,input().split())) Up =[[] for _ in range(N+1)] Down=[[] for _ in range(N+1)] for _ in range(M): u,v=map(int,input().split()) if A[u]>A[v]: Up[v].append(u) Down[u].append(v) elif A[u]