#pragma GCC optimize("O3") #include using namespace std; #define rep(i, a, n) for (int i = a; i < (int)(n); i++) using ll = long long; const ll INF = 1ll << 60; int main() { ll n, m; cin >> n >> m; vector> graph(n); rep(i, 0, m) { ll u, v; cin >> u >> v; u--; v--; graph[u].push_back(v); graph[v].push_back(u); } ll iwi; cin >> iwi; set exist; rep(_, 0, iwi) { ll x; cin >> x; x--; exist.insert(x); } vector> dist(n, vector(5, INF)); dist[0][0] = 0; queue> q; q.push({0, 0}); while (!q.empty()) { auto [pos, seen] = q.front(); cout << pos << " " << seen << endl; q.pop(); for (auto &nex : graph[pos]) { ll nex_seen = seen; if (exist.count(nex)) { nex_seen++; } else { nex_seen = 0; } if (nex_seen >= 5) { continue; } ll new_dist = dist[pos][seen] + 1; if (new_dist < dist[nex][nex_seen]) { dist[nex][nex_seen] = new_dist; q.push({nex, nex_seen}); } } } ll ans = INF; rep(i, 0, 5) { ans = min(ans, dist[n - 1][i]); } if (ans == INF) { cout << -1 << endl; } else { cout << ans << endl; } }