#include #include #include #include #include using namespace std; using ll = long long; using P = pair; using tu = tuple; int main(void){ int n, m; cin >> n >> m; vector> to(n); for(int i=0; i> u >> v; u--, v--; to[u].push_back(v); to[v].push_back(u); } vector exi(n); int k; cin >> k; for(int i=0; i> a; a--; exi[a]++; } int inf=1e8; vector dist(n, vector(5, 1e8)); queue bfs; bfs.emplace(0, 0, 0); while(bfs.size()){ auto [idx, d, cnt]=bfs.front(); bfs.pop(); if(dist[idx][cnt]!=inf) continue; dist[idx][cnt]=d; for(auto p:to[idx]){ if(exi[p]){ if(cnt<4){ bfs.emplace(p, d+1, cnt+1); } } else{ bfs.emplace(p, d+1, 0); } } } int ans=1e8; for(int i=0; i<5; i++) ans=min(ans, dist[n-1][i]); if(ans==1e8) cout << -1 << endl; else cout << ans << endl; return 0; }