import sys input = sys.stdin.readline N,M=map(int,input().split()) P=list(map(int,input().split())) for i in range(N): P[i]-=1 Friends=[0]*N for i in range(M): a,b=map(int,input().split()) a-=1 b-=1 Friends[a]|=1<