func_code_string: #include <bits/stdc++.h>   using namespace std;   inline long long read() {     register long long x = 0, f = 1;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   const long long N = 1e5 + 10;   const long long M = N;   const long long INF = 1e16;   struct edge {     long long u, v, w, next;     bool operator<(const edge &x) const { return w < x.w; }   } e[M << 1];   long long head[N], cnt;   void add(long long u, long long v, long long w = 0) {     e[++cnt] = (edge){u, v, w, head[u]};     head[u] = cnt;   }   long long n, m, k, ans = INF;   long long dis[N], s[N], from[N];   bool vis[N];   struct node {     long long u, d;     bool operator<(const node &x) const { return d > x.d; }   };   priority_queue<node> q;   void Dij() {     for (long long i = 1; i <= n; i++) from[i] = vis[i] = 0, dis[i] = INF;     for (long long i = 1; i <= k; i++)       from[s[i]] = s[i], dis[s[i]] = 0, q.push((node){s[i], 0});     while (!q.empty()) {       long long u = q.top().u;       q.pop();       if (vis[u]) continue;       vis[u] = 1;       for (long long i = head[u]; i; i = e[i].next) {         long long v = e[i].v;         if (vis[v]) continue;         if (dis[v] > dis[u] + e[i].w) {           dis[v] = dis[u] + e[i].w;           from[v] = from[u];           q.push((node){v, dis[v]});         }       }     }   }   long long fa[N];   long long find(long long x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }   void krus() {     for (long long i = 1; i <= cnt; i++) {       e[i].w += dis[e[i].u] + dis[e[i].v];       e[i].u = from[e[i].u], e[i].v = from[e[i].v];     }     sort(e + 1, e + cnt + 1);     for (long long i = 1; i <= cnt; i++) {       long long fx = find(e[i].u), fy = find(e[i].v);       if (fx == fy) continue;       ans += e[i].w;       fa[fx] = fy;     }   }   signed main() {     n = read(), m = read();     for (long long i = 1; i <= n; i++) fa[i] = i;     for (long long i = 1; i <= m; i++) {       long long u = read(), v = read(), w = read();       add(u, v, w), add(v, u, w);     }     s[k = 1] = 1;     Dij();     k = read();     for (long long i = 1; i <= k; i++) {       s[i] = read();       ans = min(ans, dis[s[i]]);     }     Dij();     krus();     cout << ans;   }   