//COP 4516 [Spring 2026] - Individual Contest 5
//Shuttle Routes
//Solution by Jackson Simoneau

#include <bits/stdc++.h>
using namespace std;

int main() {
    const int INF = 2e9;
    int t; cin >> t;

    while(t--) {
        int n, m, s;
        cin >> n >> m >> s;

        //Build the adjacency list
        //Edges are stored as {node, cost}
        vector<vector<pair<int, int>>> adj(n+1);
        for(int i = 0; i < m; i++) {
            int a, b, c;
            cin >> a >> b >> c;
            adj[a].push_back({b, c});
            adj[b].push_back({a, c});
        }

        //Run Dijkstra's from node 1
        //This allows us to compute the distance to all other nodes efficiently

        //Stores minimum distance from node 1 to each node
        vector<int> d(n+1, INF);
        d[1] = 0; //By definition

        //Use a min priority queue to process nodes in increasing order of distance
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
        q.push({0, 1});

        while(!q.empty()) {
            //u is the current node being processed
            int u = q.top().second; q.pop();
            //Check all of the edges at node u
            for(auto e : adj[u]) {
                //v is the next node, c is the travel time
                int v = e.first, c = e.second;
                //If a route through node u is better to reach node v, update d[v]
                if(d[u] + c < d[v]) {
                    d[v] = d[u] + c;
                    //Add node v to the list of nodes to process
                    q.push({d[v], v});
                }
            }
        }

        //With the distances computed in reverse, we can now answer distance queries in constant time
        //Now, the distance of node x to node 1 is simply d[x]
        for(int i = 0; i < s; i++) {
            int x; cin >> x;
            cout << d[x] << '\n';
        }
    }
}