from collections import deque n, m = map(int, input().split()) g = [[] for _ in range(n)] inf = int(1e9) for _ in range(m): u, v = map(int, input().split()) u, v = u - 1, v - 1 g[u].append(v) g[v].append(u) k = int(input()) a = list(map(int, input().split())) if k else [] is_yiwiy = [0] * n for v in a: is_yiwiy[v - 1] = 1 dp = [[inf] * 5 for _ in range(n)] dp[0][0] = 0 q = deque([(0, 0)]) while q: x, c = q.popleft() for y in g[x]: nc = 0 if not is_yiwiy[y] else c + 1 if nc >= 5: continue if dp[y][nc] != inf: continue dp[y][nc] = dp[x][c] + 1 q.append((y, nc)) ans = min(dp[-1]) print(-1 if ans == inf else ans)