from collections import deque N,M=map(int,input().split()) E=[[] for i in range(N)] for i in range(M): x,y=map(int,input().split()) x-=1 y-=1 E[x].append(y) E[y].append(x) K=int(input()) if K!=0: A=list(map(int,input().split())) X=[0]*N for a in A: X[a-1]=1 DP=[[1<<60]*N for i in range(6)] DP[0][0]=0 Q=[(0,0)] Q=deque(Q) while Q: now,iwi=Q.popleft() for to in E[now]: if X[to]==0: if DP[0][to]>DP[iwi][now]+1: DP[0][to]=DP[iwi][now]+1 Q.append((to,0)) else: if iwi+1<5 and DP[iwi+1][to]>DP[iwi][now]+1: DP[iwi+1][to]=DP[iwi][now]+1 Q.append((to,iwi+1)) ANS=1<<60 for i in range(6): ANS=min(ANS,DP[i][N-1]) if ANS==1<<60: print(-1) else: print(ANS)