from collections import deque N,M = list(map(int,input().split())) edge = [[] for _ in range(N)] for _ in range(M): u,v = list(map(int,input().split())) u -= 1;v -= 1 edge[u].append(v) edge[v].append(u) K = int(input()) if(K > 0): A = set(map(lambda x:int(x)-1,input().split())) else: A = set() q = deque([(0,0,0)]) visited = set() while(q): v,iwai,now = q.popleft() if((iwai,now) in visited):continue visited.add((iwai,now)) if(now == N-1): print(v) exit() for i in edge[now]: next_iwai = iwai + 1 if i in A else 0 if(next_iwai == 5):continue q.append((v+1,next_iwai,i)) print(-1)