#include #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define all(obj) (obj).begin(), (obj).end() using ll = long long; using namespace std; int main() { int N,M,K;cin>>N>>M; vector> gr(N); rep(i,M){ int u,v;cin>>u>>v; u--;v--; gr[u].push_back(v); gr[v].push_back(u); } cin>>K; set A; rep(i,K){ int a;cin>>a; A.insert(a-1); } const ll INF =1e12 ; vector> seen(N,vector(5,INF)); seen[0][0] = 0; queue> qu; qu.push({0,0}); seen[0][0] = 0; while(!qu.empty()){ auto [crnt,met] = qu.front(); qu.pop(); for(int nx:gr[crnt]){ bool isiwi = (A.count(nx)==1); if(!isiwi){ if( seen[nx][0] == INF){ seen[nx][0] = seen[crnt][met]+1; qu.push({nx,0}); } }else{ if( met == 4) continue; if( seen[nx][met+1]==INF){ seen[nx][met+1] = seen[crnt][met]+1; qu.push({nx,met+1}); } } } } ll ans = INF; for(int i = 0; i <5; i++){ ans = min(ans,seen[N-1][i]); } if(ans == INF){ cout << -1 << endl; }else{ cout << ans << endl; } }