#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m; cin >> n >> m; vector> edges(m); rep(i, m) { int u, v; cin >> u >> v; --u, --v; edges[i] = { u, v }; } int k; cin >> k; set p; rep(i, k) { int x; cin >> x; --x; p.insert(x); } vector Graph(6 * n, vector()); for (auto [u, v] : edges) { rep(x, 5) { int nu = u + n * x, nv = v + n * (p.contains(v) ? x + 1 : 0); Graph[nu].push_back(nv); } rep(x, 5) { int nv = v + n * x, nu = u + n * (p.contains(u) ? x + 1 : 0); Graph[nv].push_back(nu); } } constexpr int INF = 1e9; vector dist(6 * n, INF); dist[0] = 0; queue q; q.push(0); while (!q.empty()) { int u = q.front(); q.pop(); for (int v : Graph[u]) { if (dist[v] > dist[u] + 1) { dist[v] = dist[u] + 1; q.push(v); } } } int ans = INF; rep(x, 6) ans = min(ans, dist[(n - 1) + n * x]); if (ans == INF) ans = -1; cout << ans << '\n'; return 0; }