# Arup Guha
# 4/10/2026
# Solution to COP 4516 Problem: Shuttle Routes

import heapq

def dijkstras(g,s):

    # Number of vertices.
    n = len(g)

    # Everything is far away.
    dist = [1000000000000]*n

    # Who we have shortest distances to.
    done = [False]*n
    numDone = 0

    # The source is 0.
    dist[s] = 0

    # Set up Priority Queue for Dijkstras.
    myheap = []

    # Dummy edge to source.
    heapq.heappush(myheap, [0,s,s])

    # When Dijkstra's should run.
    while numDone < n and len(myheap) > 0:

        # The current edge.
        curEdge = heapq.heappop(myheap)
        to = curEdge[2]

        # No need.
        if done[to]:
            continue

        # Mark as done.
        done[to] = True
        numDone += 1

        # Enqueue estimates based on these edges.
        for x in g[to]:
            
            # New vertex, distance.
            newV = x[2]
            newD = dist[to] + x[0]

            # This is vetter.
            if newD < dist[newV]:

                # Update.
                dist[newV] = newD

                # New estimate to x[2].
                heapq.heappush(myheap, [newD, to, newV])

    return dist


def main():

    # Process cases.
    nC = int(input())
    for loop in range(nC):

        toks = input().split()
        n = int(toks[0])
        e = int(toks[1])
        q = int(toks[2])

        # First the graph is n empty lists.
        g = []
        for i in range(n):
            g.append([])

        # Add edges.
        for i in range(e):
            toks = [int(x) for x in input().split()]
            mye1 = [toks[2], toks[0]-1, toks[1]-1]
            mye2 = [toks[2], toks[1]-1, toks[0]-1]
            g[toks[0]-1].append(mye1)
            g[toks[1]-1].append(mye2)

        # Run from "end"
        dist = dijkstras(g,0)

        # Handle queries.
        for i in range(q):
            v = int(input())
            print(dist[v-1])

main()

    

    
        

    
