import heapq N,M,s,t = map(int,input().split()) P = [0]+list(map(int,input().split())) G = {i:[] for i in range(1,N+1)} for _ in range(M): a,b = map(int,input().split()) G[a].append(b) G[b].append(a) T = [[i,0] for i in range(N+1)] def tfind(x): while T[x][0]!=x: x=T[x][0] return T[x][0] def tunion(x,y): rx = tfind(x) ry = tfind(y) if rx==ry: return if T[rx][1]>T[ry][1]: T[ry][0] = rx elif T[rx][1]