#include using namespace std; using edge = tuple; int main() { int n, m, k; cin >> n >> m >> k; vector must(m); for (int i = 0; i < k; i++) { int r; cin >> r; r--; must.at(r) = true; } const int s = 1 << k; vector to[n]; int idx = 0; for (int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; a--; b--; if (must.at(i)) { idx++; to[a].emplace_back(b, c, idx); to[b].emplace_back(a, c, idx); } to[a].emplace_back(b, c, 0); to[b].emplace_back(a, c, 0); } vector dist(n, vector(s, 1e18)); priority_queue, greater> q; q.emplace(0, 0, 0); while (not q.empty()) { auto [d0, v, seen] = q.top(); q.pop(); if (d0 >= dist[v][seen]) { continue; } dist[v][seen] = d0; for (auto &&[c, d_edge, r_idx] : to[v]) { int seen_new = seen; if (r_idx) { seen_new |= 1 << (r_idx - 1); } if (d0 + d_edge >= dist[c][seen_new]) { continue; } q.emplace(d0 + d_edge, c, seen_new); } } cout << dist.back().back() << endl; return 0; }