#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector> graph(N); vector used(N), exist(N); while(M--) { int U, V; cin >> U >> V; U--, V--; graph[U].push_back(V); graph[V].push_back(U); } int K; cin >> K; while(K--) { int A; cin >> A; exist[A-1] = true; } queue> now; vector ans(N, INT_MAX), cnt(N, 5); now.push({0, 0, 0}); cnt[0] = 0; ans[0] = 0; while(!now.empty()) { auto [c, n, a] = now.front(); now.pop(); bool safe = false; for(int to : graph[n]) safe |= !exist[to]; if(safe && cnt[n] > 1) { now.push({1, n, a + 2}); cnt[n] = 1; } for(int to : graph[n]) { if(cnt[to] <= c + 1) continue; c = (exist[to] ? c + 1 : 0); now.push({c, to, a + 1}); cnt[to] = c; ans[to] = min(ans[to], a + 1); } } cout << (ans[N-1] == INT_MAX ? -1 : ans[N-1]) << endl; }