n,m = map(int,input().split()) g = [[] for _ in range(n)] for _ in range(m): u,v = map(lambda x:int(x)-1,input().split()) g[u].append(v) g[v].append(u) k = int(input()) iwai = [False] * n if k > 0: a = list(map(lambda x:int(x)-1,input().split())) for v in a: iwai[v] = True from collections import deque,defaultdict,Counter def bfs(v): visited = [[False] * 5 for _ in range(n)] dq = deque([(v, 0, 0)]) while dq: v, c, d = dq.popleft() if v == n-1: exit(print(d)) if visited[v][c]: continue visited[v][c] = True for nv in g[v]: if not iwai[nv]: dq.append((nv, 0, d+1)) else: if c+1 < 5: dq.append((nv, c+1, d+1)) bfs(0) print(-1)