#include using namespace std; using edge = pair; using graph = vector; 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 * s]; int idx = 0; for (int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; a--; b--; for (int j = 0; j < s; j++) { if (must.at(i)) { to[a * s + j].emplace_back(b * s + (j | (1 << idx)), c); to[b * s + j].emplace_back(a * s + (j | (1 << idx)), c); } else { to[a * s + j].emplace_back(b * s + j, c); to[b * s + j].emplace_back(a * s + j, c); } } if (must.at(i)) { idx++; } } vector dist(n * s, 2e9); priority_queue, greater> q; q.emplace(0, 0); while (not q.empty()) { auto [d0, v] = q.top(); q.pop(); if (d0 >= dist.at(v)) { continue; } dist.at(v) = d0; for (auto &&[c, d_edge] : to[v]) { if (d0 + d_edge >= dist.at(c)) { continue; } q.emplace(d0 + d_edge, c); } } cout << dist.back() << endl; return 0; }