#include using namespace std; using ll = long long; 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, LLONG_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(); for(int to : graph[n]) { if(cnt[to] <= c + 1) continue; now.push({exist[to] ? c + 1 : 0, to, a + 1}); cnt[to] = exist[to] ? c + 1 : 0; ans[to] = min(ans[to], a + 1); } } cout << (ans[N-1] == LLONG_MAX ? -1 : ans[N-1]) << endl; }